0

I am using magento 1.9 version. In my site i enabled menu highlightion when it is clicked using php. It is working fine when disabled the cache.

But after enabled cache it highlights the previous selected menu until i cleared the cache.

How to fix it.

0

This sounds like a typical case of block cache. The footer and header have block cache enabled by default.

You could copy over the file

app/code/core/Mage/Page/Block/Html/Topmenu.php

to

app/code/local/Mage/Page/Block/Html/Topmenu.php

Then look at the function getCacheKeyInfo(). You will want to add a value to the $shortCacheId which makes it unique to the current selected menu option.

$currentUrl = Mage::helper('core/url')->getCurrentUrl();

$shortCacheId = array(
    'TOPMENU',
    Mage::app()->getStore()->getId(),
    Mage::getDesign()->getPackageName(),
    Mage::getDesign()->getTheme('template'),
    Mage::getSingleton('customer/session')->getCustomerGroupId(),
    'template' => $this->getTemplate(),
    'name' => $this->getNameInLayout(),
    $this->getCurrentEntityKey(),
    $currentUrl
);

Something like that, not sure the current url is the option as it could be quite long.

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.