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.


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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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