Skip to content Skip to navigation

Menu Tricks #3: Automating Virtual Menu Position for Specific Content Types

As a serious navigation advocate, it drives me crazy to have an active "Blog" or "Calendar" link in my main menu when I'm looking at the overview pages for that section, but then the active link goes away when I look at a specific Event or Blog Post. Am I in the Calendar section or not?

Enter one of my favorite Drupal modules: Menu Position.

The Menu Position Module

Menu Position allows you to make it appear that a piece of content is in a certain place in the menu without having to actually place it there, based on conditions you can set. Meaning, I can tell Drupal to "pretend" that every blog post is in the main menu under Blog and if I'm looking at a Blog Post, the main Blog link will be active. Win!

Say I didn't have this module, but really wanted "Blog" in my main menu to be active when someone is reading a Blog Post node. My only real option is to add every blog post to the menu, but that's a lot of work and would create a mess in my menu! Not worth the hassle, even if you have the same pet peeves as me.

Configuring Menu Position

Configuring Menu Position is pretty straight forward once you've enabled the module. Here's an example wherein I will place all Articles under "What's New."

  1. Go to /admin/structure/menu-position/add
  2. Title your Menu Position. Mine is called "Place Articles Under What's New" (see screenshot)
  3. Choose the Parent menu Item. In my example "What's New" (see screenshot)
  4. In Conditions, select the Content Type you want to make a Menu Position rule for. Mine is "Article"
  5. And Save

You can also make menu position rules based on path, user role, or taxonomy.

Screenshot of Menu Position Configuration

Menu Position and Stanford Sites

Menu Position is on the short list of modules to be added to the Stanford Sites platform. Coming soon!

Do you have any menu pet peeves like me? What do you think makes for great navigation?