Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying to add custom css class to a particular menu, same task mentioned here.

I moved a little further and found this article. So I put following code in template.php:

<?php
function phptemplate_menu_tree($tree) {
  if ($tree == menu_tree()) {
    $output .= "<ul id=\"foo\" class=\"bar\">";
    $output .= $tree;
    $output .= "</ul>\n";
    return $output;
 } else {
  return '<ul class="menu">'. $tree .'</ul>';

 }
}
?>

but constantly getting 502 error when trying to compare $tree and menu_tree().

Can anyone suggest what am I doing wrong?

UPDATE

I've fixed the initial issue in the question and posted the solution here. Hope it helps.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You cannot call menu_tree() from within theme_menu_tree() because menu_tree() contains a call to theme_menu_tree(). Your code contains an infinite loop.

share|improve this answer
    
Thanks for reply, however menu_tree() in D6 has default argument 'navigation', and that is the one I need to customize. –  Vlad T. Dec 21 '12 at 18:04
    
Attempting to run menu_tree() without passing parameters yields a log message, "call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'garland_menu_tree' was given in /includes/theme.inc on line 656." I think menu_tree() is failing and parameters are the issue. –  beth Dec 21 '12 at 19:04
    
Further debugging indicates that theme() is failing because it doesn't like something about the hook parameter. –  beth Dec 21 '12 at 19:32
    
I was partly correct. Edited answer. –  beth Dec 21 '12 at 20:02
    
Whoa, that explains the issue, thanks! –  Vlad T. Dec 21 '12 at 20:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.