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

pjabode’s picture

I 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.

arianek’s picture

pjabode - 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? ;)

arianek’s picture

I 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

altrugon’s picture

Status: Needs review » Fixed

Thank you, looks good.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

WilliamB’s picture

Component: New documentation » Correction/Clarification

But 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

Carolyn’s picture

Status: Closed (fixed) » Active
Issue tags: +theming, +d7docs

tags

arianek’s picture

can you please open a new issue and revert this one to closed? thanks!

WilliamB’s picture

Status: Active » Closed (fixed)