<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

2 Answers 2


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.

  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);
  • Yes, already been done. Sub-menus is shown if I load the menu in a block but not with the above code. Please help Commented Jan 17, 2014 at 9:22
  • see my update in the answer
    – milkovsky
    Commented Jan 17, 2014 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. :) Commented Jan 27, 2014 at 2:49
  • Sorry, don't have a lot of time for research. Please see drupal.stackexchange.com/questions/59216/…
    – milkovsky
    Commented Jan 27, 2014 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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