Background
My drupal site has lots of menu items created by views pages (e.g. "/events" and "/news").
The views show nodes of a particular type (e.g. "Events" and "News").
The nodes are not menu items (and I don't want them to be).
But, the nodes share a common path (e.g. "/events/awesome-event-1" and "/news/breaking-news-item").

Problem
If I set up a menu block to follow the active menu item, the menu context is lost when I get to a node.
ie. since there is no active menu item, the menu block shows the top-most menu.
I want my subnavigation menu to appear contextually for nodes whose paths match a menu item.
e.g. when i'm looking at an Event node, I want to see all the menu items under "/events".

I know this can be done by mechanically creating a new menu block for every section, and assigning it by path in block settings.
However, this is tedious and unsustainable - I would like a single block that takes care of this.

Solution
I created a "default nav" block based on 2nd-level primary navigation.
I created the attached module that implements hook_menu_block_tree_alter().
My hook_menu_block_tree_alter() implementation searches the menu tree for a menu item with a path that matches the request path, as described above.

It's not perfect, but it gets the job done for me.
I hope it will help someone else.

I'm posting this as a feature request because I think it could be useful as a configuration option for menu_blocks.
Though this attachment isn't a patch, but a proof of concept implemented as a third-party module.
If other folks would benefit from such a feature, I'd be happy to make it into a patch.
There are some inefficiencies built into this module which could probably be solved by patching (or duplicating effort from) menu_block module.

CommentFileSizeAuthor
#1 default_menu_block.zip2.46 KBAaronBauman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AaronBauman’s picture

FileSize
2.46 KB
SeriousMatters’s picture

Landed here via Google. I am also having trouble with getting menu block to display for nodes that are not on a menu, such as news articles. This module seems to be exactly what I am looking for, except it's not for D7. I'd love to see this in future release of Menu Block, or as a patch.

Dave Reid’s picture

I think you might be looking for http://drupal.org/project/menu_position?

AaronBauman’s picture

Status: Needs review » Fixed

menu_position seems to accomplish the same thing as my submission in #1
Thanks for the tip Dave

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

SeriousMatters’s picture

Actually, I had been using menu_position and I came here because it does not resolve the issue. I will explain it with a simple blog example:

- there are blog articles (content type)

- each blog article has a category (taxonomy term)

- using path_auto, categories have taxonomy pages with path /blog/category-name

- using path_auto, blog articles have path /blog/category-name/article-title

A menu_position rule can set the category pages under the /blog menu item.

But the blog articles cannot be set to under /blog/category-name because category-name are not existing menu items.

Perhaps what I am raising here is not just for menu_block.