Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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?


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

share|improve this question
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

Your Answer


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.