1

I am trying to add a "view all" link to show under the main categories in my main menu.

Right now it would show:

category1
  - subcat1
  - subcat2
  - subcat3
category2
  - subcat1
  - subcat2
  - subcat3

I am trying to make it show:

category1
  - subcat1
  - subcat2
  - subcat3
  - view all
category2
  - subcat1
  - subcat2
  - subcat3
  - view all

Here is the menu code I am working with.

<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div id="<?php echo $menu_type ?>" class="nav-container<?php if($menu_stay_on_top): echo " stay-top"; endif;?>">
    <div class="nav-inner hidden-tablet hidden-phone">
    <ul id="nav">
        <!-- <li class="menu-logo"><a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>"><img src="<?php echo $this->getSkinUrl('images/logo-small.png')?>" /></a></li> -->    
        <?php echo $_menu ?>
        <?php if (($block_custom_menu = $this->getLayout()->createBlock('cms/block')->setBlockId('block_custom_menu')->toHtml()) && $menu_type == 'wide-menu'): ?>
        <li class="nav-custom-link level0 level-top parent"><a class="level-top" href="#"><span><?php echo Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('block_custom_menu')->getTitle(); ?></span></a>
        <ul class="level0">
            <div class="header-nav-dropdown-wrapper">
                <?php echo $block_custom_menu;?>
<li><a href="#"><span><?php echo Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('block_custom_menu')->getTitle(); ?></span></a>
            </div>

        </ul>
        </li>
        <?php endif;?>
    </ul>
    </div> 

I just need to add a "view all" link at the bottom of the list of sub categories (only those 2 levels), which will just link to that sub category. So a duplicate link of the sub category but named view all.

Any guidance would be greatly appreciated.

  • 2
    This feature (or pretty close to what you want) is actually built in to Magento 1.9.0.1's RWD design package. Perhaps taking a look @ it would give you some direction. – Reid Blomquist Aug 21 '14 at 23:04
1

I assume you need this for a version before 1.9 (because in 1.9 this happens by default).

You need to rewrite the method Mage_Page_Block_Html_Topmenu::_getHtml After the line $html .= $this->_getHtml($child, $childrenWrapClass); you need to add something like this:

if ($parentLevel == 1) {
   $html .= '<li><a href="<?php echo $child->getUrl()?>"'.Mage::helper('catalog')->__('view all').'</li>';
}
  • Hello Marius , I am using magento 1.9.3.4 and I want exactly this . I have theme default mega menu, but you said this is happens default in magento 1.9 so can you please tell me , where can i achive this? – H_Parekh Nov 28 '17 at 9:51
  • I have no idea how the mega menu works. – Marius Nov 28 '17 at 10:10
  • you can see my question from above link – H_Parekh Nov 28 '17 at 10:33
  • i found that module have "TopMenu.php" block file for that – H_Parekh Nov 28 '17 at 10:34

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.