Posted by floown on April 6, 2009 at 3:13pm
| Project: | Menu Trails |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
Hello
I have configured Active trail in the admin but with my zen theme it does not work out the box. Should I edit the template.php and add some lines?
The documentation don't speak about it, it seems to be so simple :)
Thx a lot if you can share a solution.
Comments
#1
I'm also seeing this issue. Everything appears to be installed and configured correctly, but it doesn't appear to be working properly. It won't set the active status for node pages and I can't tell if there's something else I should be doing. I haven't modified the Zen theme code at all. Just changed CSS.
#2
I'm also having the same problem. I found that Zen overrides the phptemplate_menu_item_link() function, in it's main template.php file (not the one of the sub-theme). I tried removing the override but it still doesn't work. Hope that helps,
Bitstream
#3
I fixed it. That's how i did that:
First, in the READMET.txt file of the module, there is a snippet, which you should put in your template.php file. The snippet is:
function _phptemplate_variables($hook, $vars = array()) {switch ($hook) { // what function is active?
case 'page': // page is where menu comes into play
// set the primary links
$vars['primary_links'] = menutrails_primary_links(1);
// you may want to also override secondary_links
$vars['secondary_links'] = menutrails_primary_links(2);
break;
}
}
But when you put it in template.php file of your zen sub-theme, it echoes an error. The thing is that this function is already defined in the original zen template.php file. So, in order to fix this issue, you have to merge the two functions.
The following code is my current zen/template.php file:
function _phptemplate_variables($hook, $vars = array()) {
global $theme_key;
// Allow modules to add or alter variables.
// This construct ensures that we can keep a reference through
// call_user_func_array.
$args = array(&$vars, $hook);
foreach (module_implements('preprocess') as $module) {
if ($module != 'search') { // Don't call search_preprocess().
$function = $module .'_preprocess';
call_user_func_array($function, $args);
}
}
foreach (module_implements('preprocess_'. $hook) as $module) {
$function = $module .'_preprocess_'. $hook;
call_user_func_array($function, $args);
}
// Allow the Zen base theme to add or alter variables.
if ($theme_key != 'zen') {
zen_preprocess($vars, $hook);
$function = 'zen_preprocess_'. $hook;
if (function_exists($function)) {
$function($vars, $hook);
}
}
// Allow a sub-theme to add or alter variables.
$function = $theme_key .'_preprocess';
if (function_exists($function)) {
$function($vars, $hook);
}
else {
$function = 'phptemplate_preprocess';
if (function_exists($function)) {
$function($vars, $hook);
}
}
$function = $theme_key .'_preprocess_'. $hook;
if (function_exists($function)) {
$function($vars, $hook);
}
else {
$function = 'phptemplate_preprocess_'. $hook;
if (function_exists($function)) {
$function($vars, $hook);
}
}
switch ($hook) { // what function is active?
case 'page': // page is where menu comes into play
// set the primary links
$vars['primary_links'] = menutrails_primary_links(1);
// you may want to also override secondary_links
$vars['secondary_links'] = menutrails_primary_links(2);
break;
}
// The following is a deprecated function included for backwards compatibility
// with Zen 5.x-0.8 and earlier. New sub-themes should not use this function.
if (function_exists('zen_variables')) {
$vars = zen_variables($hook, $vars);
}
_zen_hook($hook); // Add support for sub-theme template files.
return $vars;
}
If you copy that code and paste it over the function definition in your zen/template.php file, it should work.
#4
Forgot to say, I'm using Drupal 5
#5
@bitstream : the bug I tell is in Menu Trails 6.x-1.0.
#6
@floown: Couple of thoughts.
Does your theme already implement an override for the theme_links() function? It would be in your template.php file and named THEMENAME_links()? If so, you'll need to reconcile the differences between your theme's _links() function and the phptemplate_links() function menutrails.module. If this is the case and you're struggling with it can you post the code for your THEMENAME_links() function.
Alternately, can you check and see if your menu li tags have a class of "active-trail" for any menu items that should be in the active trail.
I've used this module in conjunction with zen sub-themes on a number of sites so it is doable.
#7
I'm using Drupal 6.10 and I can't get menu trails to work with my Zen subtheme either. I don't see a PHP error when I install and configure trails. I don't see ANY snippet in the README.TXT file (or any other file in the folder) and since I don't see an PHP error I can't determine what to override or reconcile between the template.php in my zen vs. subtheme folder. Some more specific directions would be helpful here. I tried adding the code above to both of my template.php (zen/sub) files and nothing changed (but I realize those directions were for 5.x, not 6.x). I'm not well-versed in PHP, so maybe I'm just not understanding something that is assumed I'd know???
#8
A quick followup to my last post...I'm attaching files because it occurred to me that perhaps I'm pasting the snippet over something incorrectly. I don't see THEME_links (specifically) in my template.php files for either zen or my subtheme. Perhaps my template.php files are calling it something else related to $hooks? I'm just not PHP savvy enough I guess. I've attached template.php_tinker (from zen) and template.php_tinker_subtheme (from my subtheme). I finally found the snippet I think is being referred to in menutrails.module, but its not clear where to put it or what to overwrite (to me anyway). I think this just may be a naming convention difference between 5.x and 6.x, but if anyone can shed light on this for me, I'd really appreciate the help!
@eojthebrave: I inspected the primary link LI that I'd configred via Menutrails and I did see "active-trail", but does this mean:
- the override exists and must be reconciled?
- menutrails is working?
- I did it all correctly, but there is some other error?
#9
@Milkrow I just went through this as well.
One thing that was hung me up was forgetting to clear the theme registry after installing the module!
If you see the "active-trail" then it is working, and all you have to do is edit your CSS to add the li.active-trail class.
Something like
li.active-trail a, li a.active { color: red; }
#10
Excellent advice! Thank you!
Now I'm scratching my head on this one...
Nodes whose menu attribution is Primary Links cannot, by default, be included in submenu blocks I've created. In other words...
if...
I have a Primary Link item called "About",
I have a submenu block called "About_Submenu",
I have a node called "All About Me" (node/15)...
and...
I want to set the parent menu of node/15 to "About_Submenu"
...then the class .active-trail doesn't show in the list menu.
Rather, I seem to be forced to create a separate menu item called "All About Me" in the "About_Submenu" block and point it to node/15.
This sort of defeats the beauty of being able to create nodes and set them inside submenus via the parent menu setting, doesn't it?
Does that make sense? If so, am I configuring this all wrong? I'd really like to avoid going back and recreating sub menu items for all the nodes which are already attributed to via the parent menu settings.
Any thoughts?
#11
Marking as duplicate of #328517: Having menu highlighted when I visit individual nodes.
#12
See my comment on the duplicate ticket:
http://drupal.org/node/328517#comment-2011820
Disclaimer: Just got positive results with this fix, but don't know yet if it will work for everyone or if it doesn't introduce other problems.