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>
I just like the post shared and it would be worth when we see people giving their valuable feedback which motivates the author.Thanks for sharing.for more knowledge- Magento developer for hire
ReplyDeleteGood job... its working for me
ReplyDelete