Close

Highlight current menu item

IT-Direkt
9 years ago
#7692 Quote
Avatar
  • 2
Hi,

in MegaMenu i show all top level category in a separate menu.
Now i would like to highlight the current menu item.

For example:
Top level: Houses
Secon level: Livingroom

If i visit Livingroom i would like MegaMenu item "Houses" highlighted.

Thanking you in advance...
Deni
9 years ago
#7711 Quote
Avatar
  • Moderator
  • 389
IT-Direkt wrote:
Hi,

in MegaMenu i show all top level category in a separate menu.
Now i would like to highlight the current menu item.

For example:
Top level: Houses
Secon level: Livingroom

If i visit Livingroom i would like MegaMenu item "Houses" highlighted.

Thanking you in advance...



Hello,

The easiest way to do this is by JavaScript.

I wrote a small JS for you:

    
// Now via the class "activeTopLevelCategory" you can style your active category.
    var path = window.location.pathname;
    $('.mega-menu a[href="' + path + '"]').parents('.mega-menu > li').first().addClass('activeTopLevelCategory');


You can add this code for example in your theme javascript file: ~\Themes\your-theme\Content\scripts\your-theme.js

Now you can style the active category via the class(you can change it by your taste).

Best Regards!
Best Regards,
Mladen Staykov
Nop-Templates.com
IT-Direkt
9 years ago
#7992 Quote
Avatar
  • 2
Perfect!

Thanks...