The new theme_links($variables) function in D7 receives just an associative array to build the entire link structure, and as you can read in the documentation your "links" should be passed through the links argument as an associative array, but where and/or how do you get this array. Well, here is a example of how to do it with the user menu:
$user_menu = menu_navigation_links('user-menu');
print theme('links', array(
'links' => $user_menu,
'attributes' => array(
'id' => 'user-menu',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('User menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
));
If you are wondering what the 'user-menu' argument is in the menu_navigation_links($menu_name, $level = 0) function, it is the name of the menu to be printed. You can find the menu name for this example using this path /admin/structure/menu/manage/user-menu/edit on your Drupal site.
Obviously the $user_menu variable is not mandatory but doing it that way you can later use it in a conditional statement that is quite common in the templates.
Comments
Comment #1
pjabode commentedI had spent hours and only found disconnected pieces that didn't explain how to do this.
Much appreciated!!! I wish I found this post earlier, but better late than never.
Thanks.
Comment #2
arianek commentedpjabode - glad it was useful - i've got it earmarked to review and move into the documentation. can i consider your comment a positive review of altrugon's writeup? ;)
Comment #3
arianek commentedI made some small edits for the grammar and formatting, and posted this as the main page for the menu theming subsection of the D7 theming docs.
Please review (and mark Fixed if you think it looks good). Thanks!
http://drupal.org/node/988842
Comment #4
altrugon commentedThank you, looks good.
Comment #6
WilliamB commentedBut you only get the top level of the menu that way.
What is it is an expanded menu?
I've found that using global variable is easier to theme specific level of a menu: http://drupal.org/node/123858
Comment #7
Carolyn commentedtags
Comment #8
arianek commentedcan you please open a new issue and revert this one to closed? thanks!
Comment #9
WilliamB commented