0

I have category and sub category in top menu, i want href functionality to be disabled for category, so when i click on category it should not do any thing. Just like we have in backend magento admin panel, second tab sales, nothing happens on clicking on sales, on hover it shows subcategories.

1

The quick and dirty method. Add this javascript code to the footer

$$('a.level-top').each(function(elem){
    $(elem).href='#';
});

Slow and clean method:
You need to rewrite Mage_Catalog_Model_Observer::_addCategoriesToMenu and change this:

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

to this:

$categoryData = array(
    'name' => $category->getName(),
    'id' => $nodeId,
    'url' => (($category->getLevel() == 2) ? '#' : Mage::helper('catalog/category')->getCategoryUrl($category)),
    'is_active' => $this->_isActiveMenuCategory($category)
);
  • thanks dirty way works with one problem sometimes it shows href='#' and on page refresh some time its href changes to home page href="domain.com". – Naveen Feb 7 '14 at 9:09
  • huh? how is that possible? Do you have any other javascript that manipulates the href of the menu items? – Marius Feb 7 '14 at 9:15
  • no there is nothing else, links are active while page is loading because javascript is in footer i have to wait until full page is loaded and script is executed. I will try other way thanks – Naveen Feb 7 '14 at 9:28

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.