Closed (duplicate)
Project:
Drupal core
Version:
x.y.z
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
12 Oct 2003 at 22:10 UTC
Updated:
20 Oct 2003 at 13:47 UTC
It seems that even when there is no navigation menu the navigation block is still rendered, with no content.
I tracked the problem back to the user module, in the user_block function:
case 1:
if ($menu = menu_tree()) {
$block["subject"] = $user->uid ? $user->name : t("Navigation");
$block["content"] = "<div id=\"menu\">". $menu ."</div>";
}
The user_block already checks for menu_tree being NULL, But then I looked at menu_tree() in menu.inc, and it seems that if the all the menu_items are hidden, then menu_tree() will return an empty list.
I think I have fixed it, but I do not yet have my CVS account which I applied for. I will post the patch to the development list later.
Here is my changed menu_tree() function, just in case someone wants to go ahead and change it now.
function menu_tree($parent = "") {
global $_list;
static $trail;
if (empty($trail)) {
$trail = menu_get_trail($_GET["q"]);
}
if ($_list[$parent]["children"]) {
usort($_list[$parent]["children"], "_menu_sort");
foreach ($_list[$parent]["children"] as $item) {
/*
** Don't render the menu when it is hidden, or when it has no call-back
** nor children. The latter check avoids that useless links are being
** rendered.
*/
if ($_list[$item]["hidden"] == 0 && ($_list[$item]["callback"] || $_list[$item]["children"])) {
$style = ($_list[$item]["children"] ? (menu_in_active_trail($item) ? "expanded" : "collapsed") : "leaf");
$o_list .= "<li class=\"$style\">";
$o_list .= _render_item($item);
if (menu_in_active_trail($item)) {
$o_list .= menu_tree($item);
}
$o_list .= "</li>\n";
}
}
if( $o_list != '' )
{
$output = "\n<ul>\n";
$output .= $o_list;
$output .= "</ul>\n";
}
}
return $output;
}
Comments
Comment #1
CodeMonkeyX commentedOne addition. $o_list should be set to NULL ('') at some point before entering the foreach loop.
Comment #2
CodeMonkeyX commentedWell I submitted my patch to the devel mailing list. When it is accepted and the cvs is patched I will change this to fixed.
Comment #3
jonbob commentedThis issue was duplicated by a later bug report and fixed there.