7

I can't seem to get my sub-menus to display.

I've gone to: Home » Administration » Structure » Menus

Then, I've edited the parent menu and checked the tickbox that says "Show as expanded" - but still nothing.

The code on my page.tpl.php page for the navigation I'm referring to, is as follows:

<?php
if ($page['navigation'] || $main_menu): 
?>

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

<?php
 print render($page['navigation']); 
?>
<?php
 endif; 
?>

What am I doing wrong?

Any help would be GREATLY appreciated.

apaderno
  • 28,547
  • 16
  • 75
  • 90
Nick
  • 715
  • 2
  • 7
  • 10
  • Is it possible that the theme doesn't support sub-menus? – geaw35 Jan 20 '11 at 19:10
  • how would I find something like that out? – Nick Jan 20 '11 at 19:40
  • You can try switching your theme to one of the core themes and see if the sub-menu shows up alright. What theme (or base theme) are you working with? You can try checking the documentation for it and see if it says anything. – geaw35 Jan 20 '11 at 19:55
  • ok, so i just enabled the stark theme, and the sub menus still aren't there :( – Nick Jan 20 '11 at 20:13
  • err sorry.. not sure than.. I'm not amazingly familiar with Drupal theming. – geaw35 Jan 21 '11 at 17:20

3 Answers3

15

Make sure that the parent menu "Show as expanded" attribute is checked.

Go to admin/structure/menu/item/MENU_ITEM_ID/edit, and check "Show as expanded"

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
6

Instead of using the $main_menu variable, you can use the main-menu block, which is generated with the menu.

If you put the "Main menu" block into the "Navigation" region at admin/structure/block, print render($page['navigation']) in the page.tpl.php will print out the complete menu, including its sub menu items (children).

Just make sure you tick the "Show as expanded" option in the parent menu link.

Lastly, remove the "print theme" stuff, otherwise you end up with double menu's.

the page.tpl.php will look something like this:

<?php if ($page['navigation']): ?>
  <div id="navigation"><div class="section clearfix">  
    <?php print render($page['navigation']); ?>        
  </div></div><!-- /.section, /#navigation -->
<?php endif; ?>  
m4rinos
  • 458
  • 4
  • 9
2

The stark theme out-of-the-box doesn't show submenuus in it's main menu either (2011/04).

If you however go to admin/structure/blocks, and drag the menu block to the header region in the stark theme, it has submenus.

You'll also have two menus then, the original one without submenus and the new one with submenus. You can disable the original one in admin/appearance/stark/settings.

$2c, *-pike

commonpike
  • 10,499
  • 4
  • 65
  • 58