First create cms static block in magento back-end and put this code in your static block
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/myallcat.phtml"}}
----------------------------------------------------------------------------------------------
How to call your static block in phtml page and cms page like home page
In CMS page: <div>{{block type="cms/block" block_id="your block id"}}</div>
in phtml file: echo $this->getLayout()->createBlock('cms/block')->setBlockId('block id')->toHtml();
--------------------------------------------------------
Create PHTML file for showing category with thumbnail in directory:
app/design/frontend/default/default/template/catalog/category/myallcat.phtml
And past my bellow code:
<ul>
<?php
$children = Mage::getModel('catalog/category')->getCategories(2); // put your main root category id here
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>
<?php
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>
<?php
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>
<?php
endforeach;
?>
<?php
endforeach;
?>
<?php
endforeach;
?>
</ul>
Great Work Brother...!! very helpful..!!
ReplyDeleteThankyou
ReplyDeleteYes it works, but this other method is easier and better: http://www.creare.co.uk/magento-subcategories-category-pages.
ReplyDeleteThanks
ReplyDeleteThank you.
ReplyDeleteIts working.
I wasted around 2 days of mine for this.
Thanks a lot.
It worked man Thanks
ReplyDeletenot working in 1.9.1
ReplyDeletePhew thank you - This has been causing me an issue all day!
ReplyDeleteGreat blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
ReplyDeletemagento development company in bangalore