Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By Pedro Lozano on
In Drupal 5 you can do:
$output = menu_tree(5);
where 5 is the $mid of any menu item and you obtain the html for the subtree.
In D6 since menu_tree takes the menu internal name as argument you can only specify the entire menu.
What is the method now to render a menu subtree?
Comments
same question
That's exactly the wall I'm standing in front of right now, too :(
I just need to render 3rd-level submenus of 2nd-level nodes somewhere in my template.. any suggestions?
Looking at the way the book
Looking at the way the book module finds submenus in Drupal 6+, I'd guess this got harder:
http://api.drupal.org/api/function/book_menu_subtree_data/6
Looking at a complete tree
Looking at a complete tree obtained with menu_tree_page_data(), the top most menu elements get keys like '50000 MenuTitle ###'
50000 is an offset which increments over the menu items 50001, 50002, ... I don't know what that offset is about. There is a comment about this in the nice menu module: "// Menu sets these ghetto-ass keys in _menu_tree_check_access()."
### is the mlid (I think that equates to the 'mid' or 'pid' in D5 menu system?).
Something like this might work for you - although this will only search the first level of the menu. (This code is untested, and probably not optimized, maybe someone will improve on this in the thread)
Use Orson's Example
[edit 2 ] Sorry misunderstood the question. Orson's snipit should do the job fine for top levels. Seems like there should be an easier way, but there doesn't seem to be an obvious way to get at lower levels of the menus. Here's an approach where you can specify the menu that you're using and the id from which you want to generate
Not working as I expected..
With the above code, all I'm getting back is
Now I'm using primary-links as my menu... perhaps I'm doing something wrong
using drupal 6.8
Have a look at the
Have a look at the nice_menus module. It does this. Here is its code, watch how it pick up submenu:
You can just use nice_menus and call
theme('nice_menu', 'menu_name', $submenu_id)
.thanks
thanks, I got this working perfectly for drupal 6 with the code above.
Old thread but..
http://drupal.org/project/menu_block
druid.fi