I want to have my main navigation set as the primary links and the secondary links dependent on what link I click from the primary. For example, primary has articles, forum, about us (just using 3 for the time being). If I click articles, I want the secondary links to fill with the categories I setup for stories. If I click about us, it won't display the article categories. How do I go about doing this? Any help would be greatly appreciated. Thanks in advance!

Comments

nevets’s picture

Visit Administer > Site building > Menus > Settings and make sure "Menu containing primary links" and "Menu containing secondary links" are set to the same menu (most likely "Primary Menu" ). Then add the secondary items as children of the appropriate primary item. Your theme will also need to print the secondary menu (links).

obloxeon’s picture

Thanks, worked perfectly, but how do I make it so the primary link stays highlighted when the secondary menu is open?

gpk’s picture

I think this finally works out of the box in D6. The easiest way I've found in D5 (a real hack I'm afraid!) is to edit my theme's page.tpl.php and change the line that outputs the primary links, which will be something like this

print theme('links', $primary_links, array('class' => 'links primary-links'))

to

print str_replace('-active"', '-active active"', theme('links', $primary_links, array('class' => 'links primary-links')))

Obviously you can do whatever you want with the classes, and apply an 'id' in the same way if you want.

gpk
----
www.alexoria.co.uk

obloxeon’s picture

My page.tpl.php has this for primary and secondary:

  <?php if (isset($primary_links)): ?><div id="primary-links"><?php print theme('primary', $primary_links); ?></div><?php endif; ?>
  <?php if (isset($secondary_links)): ?><div id="secondary-links"><?php print theme('secondary', $secondary_links); ?></div><?php endif; ?>

and my template.php has this:

function wheyside_v2_primary($items = array()) {
  $menu = menu_get_item(variable_get('menu_primary_menu', 0));
  $output = '<div class="title">' . $menu['title'] . '</div>';
  $output .= theme('links', $items);
  return $output;
}

How would I change those?

gpk’s picture

You could do it in your custom theme function then! Just change the last line:

  return str_replace('-active"', '-active active"', $output); // Add class "active" to menu items in active trail.

Should work because your theme function in turn invokes theme('links', ...) which adds the (largely useless) class "menu-something-active".

gpk
----
www.alexoria.co.uk

obloxeon’s picture

Thank you so much. Worked perfectly. =)

One other thing incase you might know: If I set a link for "Home" as a primary link to "<front>", how can I show a blank secondary bar because whenever I click home or the homepage is displayed, the secondary bar which goes with the theme and look of the site isn't shown. Works fine when I have children or when I link to a static page. Any thoughts?

gpk’s picture

Finger trouble ...

gpk’s picture

>Works fine ... when I link to a static page
Don't quite follow, but maybe not important.

Just remove the PHP if (isset(..)) and endif blocks in your page.tpl.php. Then any empty primary/secondary links' div will always be shown.

gpk
----
www.alexoria.co.uk

obloxeon’s picture

Doh, totally overlooked the obvious. Thanks again. =)

NicoDruif’s picture

Hi there,

I want to achieve the same thing, in Drupal 6.4, and tried it with the four seasons theme (http://drupal.org/project/fourseasons), but am puzzled about keeping the primary links highlighted when on a second level link... I wrote a post about this as well: http://drupal.org/node/300641.

Any ideas?

Thanks in advance!

www.druifdesign.nl

sunilkumar’s picture

In Administer > Site building > Menus > Settings I cant see any options like "Menu containing primary links" and "Menu containing secondary links" in Drupal 6.10. It is "Default menu for content", "Source for the primary links" (both Primary link) and "Source for the secondary links" which is set to secondary links.

What shall I do? I will make all these three options to "primary links"?

Regards,
-S-