Display categories on home page in Magento

I am a newbie in Magento and wanted to display all categories on the Magento home page rather than a top nav menu.

I read a lot of articles on it, but nothing has helped. Please point me to the right direction.

Thanks in advance.

2 thoughts on “Display categories on home page in Magento”

  1. The code below does a couple of things, first it will get all the store’s categories – it then checks to see if they are active before continuing.

    Code Courtesy : magentocommerce forum

         /* 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 endif; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *