Closed (fixed)
Project:
Drupal core
Version:
6.3
Component:
menu system
Priority:
Critical
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 May 2007 at 14:25 UTC
Updated:
23 Dec 2008 at 12:21 UTC
Using the following piece of code, or something similar in a template.php file to override the menu tree will only apply the modified class and id to sub-menus ul's.
The parent menu still has class="menu" applied to it by theme_menu_tree in menu.inc
If theme_menu_tree in menu.inc is modified, the correct information populates to all levels of the menu.
<?php
function phptemplate_menu_tree($pid = 1) {
if ($tree = menu_tree($pid)) {
$output .= "<ul id=\"foo\" class=\"bar\">";
$output .= $tree;
$output .= "</ul>\n";
return $output;
}
}
?>
More information and the use case can be seen on the following forum thread http://drupal.org/node/140654
Comments
Comment #1
drummUnable to reproduce. Are you running any contributed modules which might be outputting the menu? What block is outputting the menu?
Comment #2
mrf commentedThe following code outputs the menu in my page.tpl.php:
The site where I first noticed the problem has the following contributed modules installed. I have since had the same problem on another site, with slightly different modules.
cck/
contemplate/
devel/
front/
imagefield/
login_destination/
pathauto/
private/
search_config/
tinymce/
webform/
Thanks for your help, I really appreciate it.
Comment #3
drummThere is the problem.. theme functions need to be called like
theme('menu_tree', 50);.Comment #4
mrf commentedThat did the trick.
Thanks for your help.
So, for my own understanding of what was going on, was I calling the original non-modified function from menu.inc rather than the one modified in template.php with my theme_menu_tree function?
Comment #5
drummThe theme() function figures out what function to call.
Comment #6
drummComment #7
senortim commentedOK total drupal newbie here needing help:
I tried the code above in drupal 6.3 by taking it into the template.php file from the "zen" theme and saving it to my own sub-theme folder. But I'm getting a PHP error saying that "menu_itemlink()" is an undefined function.
Further, I can't find "menu_tree" anywhere in the original zen folder. So where does one make the necessary changes in this solution?
Thanks.
Comment #8
ainigma32 commentedLooks like senortim either gave up or figured this out on his own. Setting to fixed.
Feel free to reopen if you think that is wrong.
- Arie