Use this configuration technique to get Drupal to connect your primary and secondary menus, so that when a top level menu item is selected, its children menu items will be displayed in a separate (secondary) menu, which you can position elsewhere on your page.
- Ensure that both the Primary links and Secondary links menus are being included within the page.tpl.php file of your theme. The following is the default code for this from the Garland theme:
<?php if (isset($primary_links)) : ?>
<?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
<?php endif; ?>
<?php if (isset($secondary_links)) : ?>
<?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?>
<?php endif; ?> - Go to Administer > Site building > Menus > Settings (admin/build/menu/settings).
- Drupal 5:
Set the Menu containing secondary links option toPrimary links
, and set the Restrict parent items to option toPrimary links
. Press the “Save configuration” button. - Drupal 6:
Set every option on the page toPrimary links
, and press the “Save configuration” button.
The Restrict parent items to (Drupal 5) and Default menu for content (Drupal 6) are the same option. What it does is makes the “Primary links” menu the default menu to add to when creating content, instead of showing a huge list of other menus you don’t need.
The Menu containing secondary links (Drupal 5) and Source for the secondary links (Drupal 6) are the same option. What it does is cause the source of the Secondary links menu to be the contextual children of the Primary links menu items, instead of being a separate unrelated “secondary menu”. By default the Secondary links menu is a not connected to the Primary links menu - it is second separate menu. This ties the two together.
- Drupal 5:
- Go to Create content > Page (node/add/page). Enter
Section
for the Title of this page. Click the “Menu settings” fieldset. AddSection
as the Menu link title, and ensure that the menu is set withPrimary Links
as the Parent item. Leave the Weight field at its default at this point, as it’s much easier to sort menu items later from the main Menu page. Click the “Save” button to save the page. - Go to Create content > Page (node/add/page). Enter
Subpage
for the Title of this page. Click the “Menu settings” fieldset. AddSubpage
as the Menu link title, and under Parent item, chooseSection
, making this page a child of Section in the menu. Click the “Save” button to save the page. - Click on “Section” in the Primary Links menu at the top of the page. You should now see the “Subpage” link already showing in a separate location below it, which is where $secondary_links has been defined in the page.tpl.php template file.
- After you’ve repeated the process to add more Secondary links within the “Section” menu item, go to Administer > Site building > Menus > Primary links. If you’re using Drupal 5, adjust the weight settings to sort the menu in the correct order. If you’re using Drupal 6, drag and drop the menu items into the correct order. When you’re done sorting, press “Save”.
Hi,
Any idea how I make secondary links absolute in Drupal? I want to redirect to a 3rd party site but everything seems to be relative to the root.
Any ideas?
Thanks,