Sub menu not displaying in Bartik Theme I am using Drupal 7.9.
I need to display main menu with sub-menu.

print theme('links__system_main_menu', array(
'links' =&gt; $main_menu,
'attributes' =&gt; array(
'id' =&gt; '',
'class' =&gt; array('menu'),),
'heading' =&gt; array(
'text' =&gt; t('Main menu'),
'level' =&gt; 'h2',
'class' =&gt; 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; 
endif; 


Even it does not display sub-menu.

Does anybody know a solution?
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:


In your theme settings (admin/appearance/settings/barti) disable "Main menu"
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.