I really only need the mlid and title text for the first level below a certain menu item. Here\'s what I\'m doing at the moment. (It works, but I suspect there may be a more dru
Here's a helper function to return a whole subtree of a menu, starting at a specified mlid. Some of the other posts only return the direct descendants of the current item; this will return ALL descendants.
By default it gives you the subtree starting with the current page, but you can pass in any menu tree (as returned by menu_build_tree) and any mlid.
function _menu_build_subtree($menu=NULL,$mlid=NULL) {
if ($menu == NULL || $mlid == NULL) {
$parent = menu_link_get_preferred();
}
$menu = !is_null($menu) ? $menu : menu_build_tree($parent['menu_name']);
$mlid = !is_null($mlid) ? $mlid : $parent['mlid'];
foreach ($menu as $branch) {
if ($branch['link']['mlid'] == $mlid) {
return $branch;
}
$twig = _menu_build_subtree($branch['below'],$mlid);
if ($twig) { return $twig; }
}
return array();
}