I am using Drupal 7.9. I need to display main menu with sub-menu.

print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => '',
'class' => array('menu'),),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),

That is the code I have used, but it does not show sub-menu items.

Then i have also tried following code :

if ($main_menu){
  $pid = variable_get('menu_main_links_source', 'main-menu');
  $tree = menu_tree($pid);
  $tree = str_replace(' class="menu"', '', $tree);
  $main_menu = drupal_render($tree);
else {
  $main_menu = FALSE;
if ($main_menu): print $main_menu; 

Even it does not display sub-menu.

Does anybody know a solution?


1 Answer 1


The main menu in Bartik only displays the first level. Since it's hardcoded in page.tpl.php there's nothing you can do about it.

Here's how to get the menu to work properly:

  1. In your theme settings (admin/appearance/settings/barti) disable "Main menu"
  2. Go to admin/structure/block and add the "Main Menu" block to the header region (or wherever you want it)

Alternatively, you can also check out the excellent Menu Block module, which generates extra customizable blocks (1st level, 2nd level, etc) for each menu.

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