January 8, 2010

add categories with images on homepage – magento

to add categories along with images on homepage
just add the code given below to your homepage from admininstration cms management.
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/list.phtml"}}
Also you need to create a list.phtml file under “/app/design/frontend/default/default/template/catalog/category/list.phtml”
and add the below given code to it:
===========================================
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open
= $this->isCategoryActive($_category); ?>
<?php
$cur_category
=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if (
$immagine = $this->getCurrentCategory()->getImageUrl()):
?> <div style="float: left; padding-right: 30px; text-align: center;">
<
div class="linkimage">
<
p>
<
a href="<?php echo $this->getCategoryUrl($_category)?>">
<
img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="135" height="135" />
<?php echo $_category->getName()?>
</a>
</
p>
</
div>
</
div> <?php endif; ?>
<?php
endforeach; ?>
================================================

No comments:

Post a Comment