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 .
{{block type="catalog/navigation" name="catalog.category"
template="catalog/category/list_category.phtml"}}
And also you need to create a list.phtml file under “/app/design/frontend/default/default/template/catalog/category/list_category.phtml”
<?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; ?>
<?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; ?>
it's grt code bro thanks posting this
ReplyDeletebut here is some problem in image and thumbnail image
if we need 2 banner image then it's give some problem
for that
i just update the base code
if ($immagine = $this->getCurrentCategory()->getThumbnail()):
ReplyDelete< src="" width="260" height="235" />
Hi Abid,
ReplyDeleteI am Chhatrapal Singh Shekhawat your Neighbour from Churu Rajasthan
I have your file in my /app/design/frontend/default/my theme folder/template/catalog/category/list_category.phtml”
and i have problem to see categary list on my home page can you help me please i am waiting your positive response
Hi
ReplyDeleteThanks for the code. It works great and very simple.
It shows just the main categories though. Is there any way to modify the code so it shows sub-categories, or even better, a way to select categories?
Thanks
Nancy
Hi Abid,
ReplyDeleteI used the code and it worked.. I don't know much at all about php coding, a little html and css and a vague understanding of the Magento file structure etc. So thanks very much. Managed to get Catalogue main images with links to show up on shop homepage instead of the all of the products... Needs a little css I think because the last two right hand side images and not aligned properly with the rest. (Images in two columns) About 10 pixels out.
Thanks
Tracey
the code is superb.. very help full...!! but i want to display category desciption... plzzz help...!!!
ReplyDeletevery helpful !
ReplyDeleteThe blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
ReplyDeletemagento development company in bangalore
hi,
ReplyDeleteI have added this code in my website but it did not work properly.
Can you please help me? how Can i show the category with images on my home page.
Code :
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/list.phtml"}}
Thanks