0

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.

0

1 Answer 1

0

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.

4
  • Thanks for reply, however menu_tree() in D6 has default argument 'navigation', and that is the one I need to customize.
    – Vlad T.
    Commented Dec 21, 2012 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
    Commented Dec 21, 2012 at 19:04
  • Further debugging indicates that theme() is failing because it doesn't like something about the hook parameter.
    – beth
    Commented Dec 21, 2012 at 19:32
  • I was partly correct. Edited answer.
    – beth
    Commented Dec 21, 2012 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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