我想出了一个解决方案 - 我没有使用自动生成的菜单块进行显示,而是创建了一个块并将以下代码放入我的模块中:
function amh_menu_block($op = 'list', $delta = 0, $edit = array())
{
if ($op == 'list') {
$blocks[0] = array(
'info' => t('AMH Menu block'),
'weight' => 0,
'status' => 1,
'region' => 'left',
);
return $blocks;
} elseif ($op == 'view') {
switch($delta) {
case 0:
$block = array(
'subject' => '',
'content' => _amh_menu_display(),
);
break;
}
return $block;
}
}
function _amh_menu_display()
{
global $user;
$content = '';
if ($user->uid != 0) {
$result = db_query('SELECT * FROM {amh_menu_permission} p LEFT JOIN {menu_custom} m ON p.menu_name = m.menu_name LEFT JOIN {users_roles} u ON p.rid = u.rid WHERE u.uid = %d OR p.rid = 2', $user->uid);
} else {
$result = db_query('SELECT * FROM {amh_menu_permission} p LEFT JOIN {menu_custom} m ON p.menu_name = m.menu_name WHERE p.rid = 1');
}
$menus = array();
while ($m = db_fetch_object($result)) {
$menu = menu_tree($m->menu_name);
if ($menu) {
$content .= "\r\n<h2>" . $m->title . "<h2>\r\n";
$content .= theme_menu_tree($menu);
}
}
return $content;
}
这似乎工作正常。