- 🇪🇸Spain juanolalla
I just released a module which just extends the MenuActiveTrail service to do exactly this: https://www.drupal.org/project/menu_active_trail_deepest →
When building active trail, Drupal assumes that the first link matching the current path is the active link.
It is not always true, especially when using the Menu Firstchild module (see http://drupal.org/node/671564 about this problem).
Consider you have this kind of menu:
item A linking to path 1
-- item B linking to path 1
---- item C linking to path 1
---- item D linking to path 2
-- item E linking to path 3
Clicking on item A, item B or item C will bring user to the same path 1.
As item A and item B are just parent containers of item C, item C should be the active link.
But Drupal shows item A as the active link, ignoring item B and item C.
To fix this bug, loop should continue until the last descendant matching current path is found:
<?php
while ($curr) {
// Terminate the loop when we find the current path in the active trail.
// patch
/*
if ($curr['link']['href'] == $item['href']) {
$trail[] = $curr['link'];
$curr = FALSE;
}
else {
*/
// Add the link if it's in the active trail, then move to the link below.
if ($curr['link']['in_active_trail']) {
$trail[] = $curr['link'];
$tree = $curr['below'] ? $curr['below'] : array();
}
list($key, $curr) = each($tree);
/*
}
*/
//~patch
}
?>
Needs work
11.0 🔥
menu system
After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I just released a module which just extends the MenuActiveTrail service to do exactly this: https://www.drupal.org/project/menu_active_trail_deepest →