Closed (fixed)
Project:
Menu Trail By Path
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2011 at 00:01 UTC
Updated:
1 Dec 2011 at 03:10 UTC
The 6.x-1.x branch only works with primary and secondary links.
To add this functionality for menus other than primary and secondary links you can add this to your template.php file in your theme.
/**
* Generate the HTML output for a menu item and submenu.
*
* @ingroup themeable
*/
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
if (!empty($extra_class)) {
$class .= ' '. $extra_class;
}
$link_array = explode('href="', $link);
$link_array = explode('"', $link_array[1]);
$link_path = trim($link_array[0], '/');
$current_path = drupal_get_path_alias($_GET['q']);
if (substr($current_path, 0, strlen($link_path)) == $link_path) {
$in_active_trail = TRUE;
}
if ($in_active_trail) {
$class .= ' active-trail';
}
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
Credits: this snippet is provided by redndahead
Comments
Comment #1
squarecandy commentedHey - thanks seriousmatters! This was perfect for what I need and I much prefer this to another module anyways.
Here's my modified code that allows for 2 levels of menu, so for example if you have a menu like thus:
and a url of /press/press-releases/my-individual-page
I wanted press and press releases to both be in the active trail but not press kits, etc...
Comment #2.0
(not verified) commentedadd credits to original provider of the code