drupal 7 active menu item is set for multiple menu links with contextual filter

216 Views Asked by At

I have 3 pages in my menu that basically link to the same page, but with a different contextual filter on them.

Is there any way to only set the correct "page" as the active page in my menu so the other links don't get the active menu item style?

These are the links:

  • xxx.ons-aanbod/% (contextual filter)
  • xxx.ons-aanbod/diversiteit (VOORGROEPEN)
  • xxx.ons-aanbod/architectuur (VOOR SCHOLEN)

enter image description here

1

There are 1 best solutions below

0
Fky On

I'm not sure but think you can hook menu links , like this :

function MODULENAME_menu_link_alter(&$item)
{
    $path = current_path(); // get path of current page displayed
    if($item['link_path']== $path) // or something like
    {
        // add class active
    }
}

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_link_alter/7.x

https://api.drupal.org/api/drupal/includes%21path.inc/function/current_path/7.x