I have created a new way to always set the active trail to current nice menu.
There are exists some patches that try to do something like mine patch, but I can't force they to work on my site - all that patches don't set the correct trail for menu. Most of them breaks when the node is not only in menu, but always in tree of one book trail.
And I create an own method to set the correct trail that uses the menu_tree_page_data() function to get the trail for specific menu.
Patch is attached. Will be good to see it in the new versions of nice menu module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Murz’s picture

Title: Patch to add 'in-trail' style to each menu item that in active trail » Patch to add 'in-active-trail' CSS style to each menu item that in active trail of current menu
Murz’s picture

Next version of patch - css style 'in-active-trail' moved to link style (a tag) instead of li tag style.
And setting this style to child items corrected.

seutje’s picture

Title: Patch to add 'in-active-trail' CSS style to each menu item that in active trail of current menu » Patch to add 'in-active-trail' CSS class to each menu item that is in active trail of current menu

corrected title

zoliky’s picture

Thanks, this patch is useful!

add1sun’s picture

Status: Needs review » Closed (duplicate)

I tried this out and it works quite nicely. I cleaned the patch up a little and have posted it back to the original issue. I'm marking this one a duplicate so we can keep all of the conversation in one place.

#219804: Set active menu trail CSS selectors

mroscar’s picture

Version: 6.x-2.x-dev » 5.x-1.4

Solved the active trail issue for myself but since I am newbie dont know how to make a small module or use in temlate.php But it work in page.tpl
To work depends on taxonomy, taxonomy breadcrumb and pathauto installed.

$tid = 0;
$terms = taxonomy_get_children($tid);

print "<ul>";
foreach ( $terms as $term ) {

if(stristr ($breadcrumb, $term->name)) {
print "<li class = active >".
l($term->name,'taxonomy/term/'.$term->tid, array('title' => $term->name)).
"</li>";
$active_term =  $term->tid;


 } else {
print "<li>".
l($term->name,'taxonomy/term/'.$term->tid, array('title' => $term->name)).
"</li>";
}
} /* end foreach */
print "</ul>";

HJulien’s picture

Component: CSS » Code

Is it possible for me to set something like this up in a case where the menu item is like a dashboard page where you can click on many things but none of them of 'children' of the parent menu item? I lose the active-trail as soon as I click off the main page. It seems that somehow I need to specify which node, pages, aliases, etc belong to that dashboard to make this work.

I thought of a module like custom breadcrumbs so I can get the backend functionality to connect the menu item to everything else but I don't want to display breadcrumbs.

Any suggestions?