Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The active trail of a menu system is not currently expanded, which is default behaviour in Drupal 6, and when not enabled means that the only time a menu is expanded is when it is set to expanded in the menu item.
Line 1040 of menu.inc
if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
$data['link']['localized_options']['attributes']['class'][] = 'active';
}
Should be something like this
if ($data['link']['href'] == $router_item['tab_root_href'] && $data['link']['href'] != $_GET['q']) {
$data['link']['localized_options']['attributes']['class'][] = 'active';
$data['expanded'] = TRUE;
}
And then it works brilliantly!
Comments
Comment #1
NewZeal CreditAttribution: NewZeal commentedOK so my solution was not what is needed and I am yet to find out exactly where the active class is applied to the anchor tag. If I make all the menu items expanded then active trail is no longer applied so I cannot control visibility using css.
Basically I cannot see how to make a menu display an expanded menu trail for the active trail in Drupal 7.
If I disable the query condition below on line 1357 of menu.inc then I can get all my child items showing and have an active class to use to theme it with:
Comment #2
BerdirThis is probably a duplicate of #942782: Custom menus never receive an active trail.
Comment #3
NewZeal CreditAttribution: NewZeal commentedYes, looks like you are correct. Hopefully this will be gone in 7.1.