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 drupal-y way.):
/**
* Get all the children menu items below 'Style Guide' and put them in this format:
* $menu_items[mlid] = 'menu-title'
* @return array
*/
function mymod_get_menu_items() {
$tree = menu_tree_all_data('primary-links');
$branches = $tree['49952 Parent Item 579']['below']; // had to dig for that ugly key
$menu_items = array();
foreach ($branches as $menu_item) {
$menu_items[$menu_item['link']['mlid']] = $menu_item['link']['title'];
}
return $menu_items;
}
Is there?
Actually there is an easy way to get that information by using menu_build_tree():
$children
contains all information you need.menu_build_tree()
checks access or translation related restrictions too so you only get what the user really should see.afaik, there isn't (i hope i am wrong). for the while, instead of digging for ugly keys, you can turn your function into a more abstract helper function by simply adding a foreach ($tree). then you can use your own logic to output what you want (mlid, in this case). here is my suggestion:
I use this : Just add your path and eventualy the menu and it will give you the child.
Have you looked into the Menu block module? Some more details about this module (from its project page):
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.