To create a menu with a sub-menu is relatively easy to set up. I had some problems getting the desired behaviour using the default functionality provided when you enable both 'Main menu' and 'Secondary menu' options in your theme settings, and then set the 'Source for the Main links' & the 'Source for the Secondary links' both to 'Main Menu' in the menu settings.
Below are a several options that got the Main menu, sub-menu working as wanted.
Main menu with seperate sub menu block
This method can be used to setup various menu/sub-menu configurations, eg. horizontal main menu with horizontal sub-menu underneath, horizontal main menu with vertical sub-menu.
- Disable the 'Secondary menu' option in your theme settings (/admin/appearance/settings). You will need to check that custom themes don't overwrite this, and also have both enabled.
- Go to Blocks area and 'Add menu block' (/admin/structure/block)
- Select the 'Advanced options'
- Use these configurations, leaving everything else as default:
- Menu: set this as your primary menu - most likely 'Main menu'
- Starting level: 2nd level (secondary)
- Check the box for 'Make the starting level follow the active menu item'
- Starting level will be: Active menu item
- Check the box for 'Expand all children of this tree'
- Save your sub-menu block and place it in the relevant block region where you want it to appear
Vertical Main menu with nested sub menu items
- Under the menu settings (/admin/structure/menu/settings) set the 'Source for the Main links' & the 'Source for the Secondary links' both to 'Main Menu'.
- Disable both 'Main menu' and 'Secondary menu' options in your theme settings (/admin/appearance/settings). You will need to check that custom themes don't overwrite this, and also have both disabled.
- Place your 'Main menu' block into a sidebar region of your choice.
Main menu with Sub-menu block in Drupal 6
Incidentally here is a little PHP snippet I used to use for creating this functionality in Drupal 6.
Add this code to your page.tpl.php
<?php if (isset($primary_links)) : ?> <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?> <?php endif; ?>
Then create a block and set the text format to PHP filtering and insert this.
<?php //show sub menu links $menuItems = menu_tree_page_data('primary-links'); foreach($menuItems as $key => $m) { //check current active menu if ($m['link']['in_active_trail'] && $menuItems [$key]['below']) { $menu = menu_tree_output($menuItems [$key]['below']); } } //print the menu print $menu; ?>

Justin Chevallier
Avid Drupal site builder & user for +10 years.
Comments
Sorry, but... you say
Sorry, but... you say "Disable the 'Secondary menu' option" and then you say "have both enabled". Now what?
Also, in Drupal 7, there is no "add menu block" under admin/structure/block, there is only "add block". And there also is no "advanced options" there either.
Misunderstanding
What I meant is that you disable the 'secondary menu' option, but that you need to check that this isn't being overwritten by your theme which might still have both enabled. I'll rephrase it so that it's a bit more explicit in it's meaning.
I'll have to check the thing about there being no 'add menu block' or advance options. Maybe it's been updated since I wrote the post.
Confirmed. No "add menu
Confirmed. No "add menu block" in D7, and no advanced options. Used to do this using the method you have described - came here to look for D7 solutions.
Ignore last comment. D7 does
Ignore last comment. D7 does not come with this functionality installed as default. To get this functionality you must install "menu block" module: drupal [dot] org/project/menu_block/
this post
You forgot to add, menu block module, needs to be added!!!
Add new comment