how to get all the menu items below a certain parent in drupal?
Posted
by sprugman
on Stack Overflow
See other posts from Stack Overflow
or by sprugman
Published on 2010-04-26T20:53:11Z
Indexed on
2010/04/26
21:03 UTC
Read the original article
Hit count: 140
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?
© Stack Overflow or respective owner