Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Very new to Drupal and a bit confused.

In order to render a menu in my theme I've been using this:

print theme('links', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links')))); 

That works a treat and gives me an extra class on the first and last list items, which I need for styling. It doesn't, however, show any of the nested sub menus. So I found this that again, worked like a charm Show all nested menu links in Drupal 7 and shows all the top-level links in the main menu and the nested ones too. This doesn't give me the extra classes on the first and last list items which I need. Is there any way to use the code from the answer above and give the extra classes on the list items?

Thanks muchly

share|improve this question

Check out the Menu Attributes module. Here is a quote about it (from the module's project page):

This simple module allows you to specify some additional attributes for menu items such as id, name, class, style, and rel.

You should use this module when

  • You want to "nofollow" certain menu items to sculpt the flow of PageRank through your site
  • You want to give a menu item an ID so you can easily select it using jQuery
  • You want to add additional classes or styles to a menu item
share|improve this answer
Boom! Nice one fella. Just what I needed. If I had some rep, I'd up-vote you...... – toby_lh Mar 5 '13 at 13:12
I did it for you. – SpaceBeers Mar 5 '13 at 13:34
Cheers SpaceBeers. Top name btw. – danbohea Mar 5 '13 at 14:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.