<div class="row" id="mainNav">
 <?php print theme('links__system_main_menu', array(
    'links' => $main_menu,
    'attributes' => array(
      'class' => 'menu',
  )); ?>

I've used the above code to load main menu in page template. This code fails to display submenus. Please suggest.

class name is missing with new code


For Drupal 8:

You must configure the block settings of Main navigation or any other menu. The default setting for Maximum number of menu levels to display is set to 1. Change this setting to Unlimited to see children displayed.

| improve this answer | |
  1. Go to /admin/structure/menu/manage/main-menu
  2. Edit your parent link
  3. Enable "Show as expanded" checkbox
  4. (Repeat the same for all the parent links)
  5. Go to the front page and see the main menu expanded.


You can use next code to render menu:

 $main_menu = variable_get('menu_main_links_source', 'main-menu');
 $tree = menu_tree($main_menu);
 print render($tree);
| improve this answer | |
  • Yes, already been done. Sub-menus is shown if I load the menu in a block but not with the above code. Please help – Suresh Alagar Jan 17 '14 at 9:22
  • see my update in the answer – milkovsky Jan 17 '14 at 12:16
  • Thank you milkovsky. Your code works but the only problem is that it has class name missing for individual list items. Please see the above screen-shot image.<br> Thanks again for the help. :) – Suresh Alagar Jan 27 '14 at 2:49
  • Sorry, don't have a lot of time for research. Please see drupal.stackexchange.com/questions/59216/… – milkovsky Jan 27 '14 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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