Im using code that i found on a magento wiki page about showing All categories (http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/getting_and_using_categories_and_subcategories).

However when i apply this to a page it just shows the words "All categories" which is a link to my categories page. But i want it to display all of my categories (the sub categories of All categories). I have put the code below

/* Get the categories that are active for the store */

/* Get the current category the user is in */

/* Get the current category path */
$_categorypath = $this->getCurrentCategoryPath();
if ($_main_categories):
    /* This bit cycles through the categories - setting the next one to current */
    foreach ($_main_categories as $_main_category):
           $layer = Mage::getSingleton('catalog/layer');

/* Write the main categories */           
<li><a href="<?php echo $this->getCurrentCategory()->getUrl()?>"><?php echo $this->getCurrentCategory()->getName();?></a></li>   


/* Check the category variable loop against the current category path if it is - print sub categories */
if (in_array($this->getCurrentCategory()->getId(), $_categorypath)): ?>
<?php $_maincategorylisting=$this->getCurrentCategory()?>                       
<?php $_categories=$this->getCurrentChildCategories()?>
<?php if($_categories->count()):?>

<? foreach ($_categories as $_category):?>                   
   <? if($_category->getIsActive()):                   
           $layer = Mage::getSingleton('catalog/layer');

<li><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></li>
    <? endif;?>
<?php /* This resets the category back to the original pages category
****     If this is not done, subsequent calls on the same page will use the last category
****    in the foreach loop
*/   ?>



<?php $layer->setCurrentCategory($_current_category); ?> 

<p>$_main_categories array was empty.</p>
<p>This might be because you are referencing this phtml file with a wrong type attribute. You should use <block type="catalog/navigation" ... /> !</p>
<?php end;?>

What would i have to change to get to to show the sub categories of All categories??

Thanks in advance

1 Answer 1


I found the answer on another wiki- http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/how_to_create_a_vertical_left_hand_menu

I just change my .phtml file to one called home_nav.phtml and added this code.

<div class="vertical-nav-container box base-mini">
<div class="vertical-nav">

<!--<div class="head">-->

<div class="block block-cart">
    <div class="block-title">
        <strong><span><?php echo $this->__('Categories') ?></span></strong>
</div><!--End block block-cart-->

<div class="block-content">

<!--</div>--><!--End Of head-->

<h4 class="no-display">
<?php echo $this->__('Category Navigation:') ?></h4>
<ul id="nav_vert">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?> </ul>
</div><!--End Of vertical-nav-->

<?php echo $this->getChildHtml('topLeftLinks') ?>

</div></div><!--End Of vertical-nav-container box base-mini-->

Then displayed the code in a block using

{{block type="catalog/navigation" name="catalog.category" template="catalog/navigation/vert_nav.phtml"}} 

a more detailed answer can be found on the wiki link at the top

Hopefully this can help soemone as i struggled with this for some time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.