在我的管理中,我启用了Show As Expanded复选框,但是子菜单没有显示。
下面是我在template.php中的代码:$trail = menu_get_active_trail();
$leaf = $trail[1];
if(!empty($leaf['has_children'])) {
$parameters = array(
'active_trail' => array($leaf['plid']),
'only_active_trail' => FALSE,
'min_depth' => $leaf['depth'] + 1,
'max_depth' => $leaf['depth'] + 2,
'conditions' => array('plid' => $leaf['mlid']),
);
$children = menu_build_tree($leaf['menu_name'], $parameters);
$vars['submenu'] = menu_tree_output($children);
}
编辑:正确的代码是:
$trail = menu_get_active_trail();
$leaf = $trail[1];
if(!empty($leaf['has_children'])) {
$parameters = array(
'active_trail' => array($leaf['plid']),
'min_depth' => $leaf['depth'] + 1,
'max_depth' => $leaf['depth'] + 3,
'conditions' => array('p1' => $leaf['mlid']),
);
$children = menu_build_tree($leaf['menu_name'], $parameters);
$vars['submenu'] = menu_tree_output($children);
}
谢谢。
'conditions' => array('plid' => $leaf['mlid']),
可能是问题所在。你应该用p1
, p2
,…过滤父