Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Show all category links at static block
 
vijay_gst
Jr. Member
 
Total Posts:  9
Joined:  2012-12-17
 

Hii friends, I want to show all categories in static block at my shop page.Help me Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lyonscg
Sr. Member
 
Avatar
Total Posts:  173
Joined:  2009-11-13
Chicago IL
 

You will need to call a phtml file into the static block:

{{block type="core/template" template="YOUR_PHTML_FILE"}}

Replace “YOUR_PHTML_FILE” with the path to your phtml file from the app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template directory.

For example, let’s say you have your phtml file named “test.phtml” in the template/page/html directory, you would replace “YOUR_PHTML_FILE” with “page/html/test.phtml”

Once that is done, add the following code to your phtml file:

<?php 
    $_helper 
Mage::helper('catalog/category');
    
$_categories $_helper->getStoreCategories();
    
    if (
count($_categories) > 0)
    
{
        
foreach($_categories as $_category)
        
{
            
echo $_category->getName().'<br />';
        
}
    }
?>

You should now have a list of all top level categories. If you want to show root and sub categories, look at this site: http://magentosnippet.blogspot.com/2011/06/getting-all-top-and-sub-categories-in.html

With a little tweaking you can get this to work in your phtml file instead of the top.phtml file.

I hope this helps

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top