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

Displaying sub categories when in a category rather than “There are no products matching the selection.”
 
GoMediaLtd
Sr. Member
 
Avatar
Total Posts:  84
Joined:  2009-11-12
Wakefield, United Kingdom
 

Hello smile

My category navigation goes something like:

Category 1
-sub category 1
-sub category 2

Basically when i click on Category 1 it displays the “There are no products matching the selection.” message.

However i would like it to display small boxes with all the sub categories in it in order to make the site more user friendly.

Has anyone done this before or know how to??

 
Magento Community Magento Community
Magento Community
Magento Community
 
miguelcpc
Jr. Member
 
Total Posts:  1
Joined:  2013-05-16
 

Hello! I would also like to do this (very much!)

Did you found a solution?

 
Magento Community Magento Community
Magento Community
Magento Community
 
indpurvesh
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2009-08-18
 

THere is few things that you need to do it

First
create a static block called sub category

{{block type=\"catalog/navigation\" template=\"catalog/navigation/subcategory_listing.phtml\"}}

Next when you click on category1 choose a block called sub category listing and save.

Now add a file called subcategory_listing.phtml

with the code below.

<?php
    $cats 
Mage::getModel(\'catalog/category\') -> loadMage::getModel(\'catalog/layer\')->getCurrentCategory()->getId()) -> getChildren();
    
$catIds explode(\',\'$cats);
    
$categories = array();
    foreach (
$catIds as $catId{
        $category 
Mage::getModel(\'catalog/category\') -> load($catId);
        
$categories[$category -> getName()= array(\'name\' => $category -> getName(), \'url\' => $category -> getUrl(), \'img\' => $category -> getImageUrl(), \'subcategories\' => Mage::getModel(\'catalog/category\') -> getCategories($catId));
    
}
    ksort
($categoriesSORT_STRING);
?>
<ul>
    
<?php foreach($categories as $name => $data): ?>
        
<li><?php echo $data[\'name\']?>
            
<a href=\"<?php echo $data[\'url\']; ?>\" title=\"<?php echo $name; ?>\">
                <
img class=\"cat-image\" src=\"<?php echo $data[\'img\']; ?>\" />
            </
a>
            <
ul>
            
<?php
                
foreach ($data[\'subcategories\'as $subcategory{
                    
echo \"<a href=\'\" $subcategory -> getUrl() . \"\'><li>\" $subcategory -> getName() . \"</li></a>\";
                
}
            ?>
            
</ul>
        </
li>
    
<?php endforeach; ?>
</ul>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top