I was trying to get all the menu items that are node creation links.
However, whatever I pass to this function as the second parameter seems to have no effect on its output at all:
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'node/add' AND menu_name = '%s' AND module = 'system' ORDER BY mlid ASC", 'navigation', 0, 1));
if ($mlid) {
$item = menu_link_load($mlid);
}
$tree = menu_tree_all_data('navigation', $item);
dsm($tree);
Giving menu_link_load() any old mlid from the table still gets me the same result from menu_tree_all_data().
This is not what I understand it should do from the documentation -- so one of the code or the docs is wrong.
Comments
Comment #1
marcvangendIt's hard to believe so little people are running into this, but it looks like this still is a bug. I think this is actually major, because the menu API is an important part of core and it should just work as advertised.
Stepping through the current D7 code, I noticed that line 1130 of includes/menu.inc says:
$parents = array(0);This seems to be the cause of the trouble. Because the $parents array always includes 0 (the root menu item), the complete tree is always returned. I quickly changed that line to
$parents = array();which seemed to fix the problem, but I have not tested if this causes trouble elsewhere.