2

I tried (without success) to show 3 different menus: - Menu1: for the home page having the subcategories : Home SubMenu1, Home SubMenu2 and Home SubMenu3 - Menu2: for the online Shop having Cat1 SubMenu1, Cat1 SubMenu2 and Cat1 SubMenu3 visible - And Menu3; visible only in the CMS pages and having the 3 sub-elements visible : Cat2 SubMenu1, Cat2 SubMenu2 and Cat2 SubMenu3

The structure of my categories is like this:

Default Category
    |– Home Menu    (Is Active : No)
    |   |– Home SubMenu1    (Is Active : Yes)
    |   |– Home SubMenu2    (Is Active : Yes)
    |   |– Home SubMenu3    (Is Active : Yes)
    |
    |– Cat1 (Is Active : No)
    |   |– Cat1 SubMenu1    (Is Active : Yes)
    |   |– Cat1 SubMenu2    (Is Active : Yes)
    |   |– Cat1 SubMenu3    (Is Active : Yes)
    |
    |– Cat2 (Is Active : No)
    |   |– Cat2 SubMenu1    (Is Active : Yes)
    |   |– Cat2 SubMenu2    (Is Active : Yes)
    |   |– Cat2 SubMenu3    (Is Active : Yes)

Any help?

Many thanks in advance!

  • Did you manage to resolve the issue Bizboss? – Sander Mangel Mar 31 '14 at 18:28
2

It's not possible with the default top navigation offered in Magento CE.

You can however write a custom extension that returns a collection of category links depending on the type of page.

class [Namespace]_[Module]_Block_Menu extends Mage_Core_Block_Template
{
   public function getMenu()
   {
      if (Mage::getSingleton('cms/page')->getIdentifier() == 'home')
      {
          $parent_id = [home cat id];
      }
      elseif (Mage::app()->getRequest()->getModuleName() == 'catalog')
      {
          $parent_id = [catalog cat id];
      }
      elseif (Mage::app()->getRequest()->getModuleName() == 'cms')
      {
          $parent_id = [cms cat id];
      }

      $main = Mage::getModel('catalog/category')->load($parent_id);
      $menu = array(
         'name' => $main->getName(),
         'url' => $main->getUrl(),
         'children' => array(),
      );

      $children = Mage::getModel('catalog/category')->getCollection()
         ->addAttributeToFilter('parent_id', $main->getId());
      foreach ($children as $item)
      {
         $menu['children'][] = array('name'=>$item->getName(), 'url'=>$item->getUrl());
      }

      return $menu;
   }
}

Now in a custom PHTML file you can use the menu array to run through all the items and build a menu.

To replace the old menu with your new one add the following to your local.xml

<reference name="header">
   <remove name="top.menu"/>
   <block type="[module]/menu" name="custom_menu" as="topMenu" template="your/custom/template.phtml"/>
</reference>

This is however a very inflexible solutions as when you change a category it might break the menu. I'm not big on promoting paid extensions but you might want to give Menubuilder a try as it provides for a lot of flexibility.

1

You can set categories in your admin. Sign in to your admin and go to catalog -> manage catagories. There you can add your new catagories according to your wish. Good luck.

updation: u need to make all of your catagories actve:yes then

  • I have already added my categories in Backend. My problem is with the Frontend... – Bizboss Oct 22 '13 at 12:36
  • make your categories status active:yes then in the admin panel – Rajeev K Tomy Oct 22 '13 at 16:43
  • Thanks a lot, but that don't solve my problem – Bizboss Oct 22 '13 at 21:28
  • sometimes it happens due to in proper installation. Try to intstall magento again as per the instruction in the official website. good luck – Rajeev K Tomy Oct 23 '13 at 1:11
  • Have you ever something like that tested? (3 different top menus) – Bizboss Oct 23 '13 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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