如何显示drupal菜单的子节点

How to show the child nodes of drupal menu

在我的管理员中,我启用了显示为展开勾选,但子菜单不显示。

这是我在 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']), 可能是问题所在。您应该使用 p1p2、... 来过滤父