• Closed by: Marek
  • Closed on: 13.07.18, 20:41
  • Reason: Closed
  • Comment: Glad to help!

Ticket #12348 - Active state on current page in the menu

Hello !

I would like to know how can I highlight the current page in the menu.
So when I am looking throught the categories and products the “Shop” item in the menu will be highlighted, the other items in the menu refer to cms pages so i want them to be highlighted when I am in the cms page.
How can i make this possible ?

Thanks !

Comments

Marek 07 Jun 2018, 10:55

Hi, Guillermo.
There is no such option, but you can do that with following code (add it to the end of /themes/alysum/assets/js/theme.js):

var currentUrl = window.location.href;
var currentLink = document.querySelector('[href="'+currentUrl+'"]');
$(currentLink).addClass('current-link');

and CSS:

#top-menu a.current-link {color:#f00 !important}
Guillermo Martínez 20 Jun 2018, 21:40

Hello, thanks marek !

It works when the menu doesn’t have a sub-menu attached also i would like to hever de the menu item “shop” when you are in any category.

Thanks

Marek 21 Jun 2018, 09:45

it requires additional code customisation. I can ask Alex to help you with that for some price