If you want to get all the menu items below a certain parent in Drupal? 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /** * Get the children of a menu item in a given menu. * * @param string $title * The title of the parent menu item. * @param string $menu * The internal menu name. * * @return array * The children of the given parent. */ function MY_MODULE_submenu_tree_all_data($title, $menu = 'primary-links') { $tree = menu_tree_all_data($menu); foreach ($tree as $branch) { if ($branch['link']['title'] == $title) { return $branch['below']; } } return array(); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.