• We are available for any Development work:
  • Email us at: programmer_heart@yahoo.com

Display Categories with images on homepage in Magento

For adding of  categories with its  images on homepage od magento  we have to add    block from admininstration cms management either by just putiing the code given below  or making the static block .

[codesyntax lang=”php”]
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/list_category.phtml"}}
[/codesyntax]
And also you need to create a list.phtml file under “/app/design/frontend/default/default/template/catalog/category/list_category.phtml”
and add the below given code to it:
[codesyntax lang=”php”]
<?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; ?>

[/codesyntax]

4 thoughts on “Display Categories with images on homepage in Magento

  1. Your code snippet here appears to have special characters inserted into it. In IE 8, it is a box. In Chrome, it is appearing as a diamond with a ? in it.

  2. I do not think there is special character. If you found it you can delete this then use. There may be inserted during the copy of code..
    thanks..

Leave a Reply

Your email address will not be published. Required fields are marked *

Current day month ye@r *

Press Enter to Search