Hello,

I'm trying to find a way to get a list of the root menus in d6 so that I could reference and call them individually later. In d5 and earlier, there was a great function, menu_get_root_menus (http://api.drupal.org/api/function/menu_get_root_menus/5), which did this. In d6, this is now missing, and after a little bit of looking, I can't seem to find something that replicates its functionality. The closest I've found is menu_get_names, which only gets the names of the menus.

I presume menu_get_root_menus was removed because that's no longer the correct way to reference menus, but is there a way to accomplish the spirit of the function, which was to return a list of the root menus and some way to individually reference them?

Comments

mradcliffe’s picture

If I understand correctly you want all children of the root plid? (pid in drupal5)

The root plid is stored in a variable $rootmenu = variable_get('menu_primary_menu',0);

$res = db_query("select * from menu_links where plid = %d and hidden = 0 order by menu_name, weight",$rootmenu);

while( $m = db_fetch_object($res) ) {
    // do something with a menu item.
}

If you want menu_router info I think a left outer join should work.

This will give you all menus directly under root, which may include primary-links, custom menus, module custom menus like devel, and navigation.

tormu’s picture

dotpex’s picture

$menu_name = menu name from menu_get_names

      $tree = menu_tree_page_data($menu_name);

You got complete menu tree in $tree array