0

My magento version is 1.9 and i am using rwd theme.

I want to remove link from the menu on homepage... I tried the following stuff but it didn't work:

  1. Create some folder as this path: app/code/local/Mage/Catalog/Block
  2. Copy file Navigation.php from app/code/core/Mage/Catalog/Block to app/code/local/Mage/Catalog/Block
  3. Go to function _renderCategoryMenuItemHtml()
    Replace the code

    $html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
    $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
    $html[] = '</a>';
    

    with this code

    if($category->getLevel()== 2 && $hasActiveChildren) {
            $html[] = '<a href="[removed]void(0);"'.$linkClass.'>';
            $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
            $html[] = '</a>';
    } else {
            $html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
            $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
            $html[] = '</a>';
    }
    
2
  • 1
    Ok, so you tried some stuff, but... what did happen (or didn't)? And what did you want to happen/achieve? I'm missing the actual question here, as "How to ...?", "Why ...?", "What ...?"
    – 7ochem
    Jun 9, 2015 at 7:50
  • i want to remove link from the menu on homepage...i tried the above stuff bt it didnt worked
    – karsh
    Jun 9, 2015 at 8:00

2 Answers 2

1

If i understand your request correctly, you want to remove a category in your main product category structure from the main menu.

You can do this in the admin of your site catalog->manage-categories. Select the category you wish to hide and under the general information tab you have the Include in Navigation Menu * option that you can set to no.

enter image description here

0

Starting version 1.7, the top menu is not rendered anymore using the app/code/core/Mage/Catalog/Block/Navigation.php block.
Instead it makes use of an event called page_block_html_topmenu_gethtml_before through which you can add anything to the top menu, not only categories.
The categories are added to the top menu using Mage_Catalog_Model_Observer::addCatalogToTopmenuItems that calls _addCategoriesToMenu from the same class
In this last mentioned method you will find the configuration of the menu item:

        $categoryData = array(
            'name' => $category->getName(),
            'id' => $nodeId,
            'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
            'is_active' => $this->_isActiveMenuCategory($category)
        );

you can replace the line 'url' with something like this:

'url' => ($category->getLevel()== 2 && $hasActiveChildren) ? '[removed]void(0);' : Mage::helper('catalog/category')->getCategoryUrl($category),
1
  • i want remove link from menu and my magento version is 1.9 rwd theme
    – karsh
    Jun 9, 2015 at 7:57

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.