Hi there, love this module but found that active-class is not added to parent items correctly.

1. I add a view of nodes onto a menu item using Menu Views
2. I visit one of those nodes
3. The single item itself is marked as active in the menu, BUT
4. The parent item does not receive the active-trail class

I would expect to see the parent menu item get the active-trail class, as it would if a normal sub-menu item was active.

Comments

aldenjacobs’s picture

Any thoughts on this? If this were somehow approached and accomplished I would use this module everywhere all the time and it would be the best thing ever.

How can I help?

markhalliwell’s picture

Version: 7.x-1.3 » 7.x-2.x-dev
Category: bug » feature

Unfortunately this problem seems, at the moment and as far as I am aware of, almost impossible to incorporate this natively in Menu Views. The main reason for this being: there really isn't a way to get two way communication between a view and the menu system.

The best solution that I could come up with after discussing this issue with others and also from implementing for other use cases in this type of scenario: use context.

In context, it is possible to give a criteria of conditions whether it be a path, node type or a variety of other conditions. Then you could set the reaction for the menu's active trail. However, see: #835090: Context Reaction: Set menu trail.

It's not really a perfect solution, but this is a rather complex problem.

markhalliwell’s picture

Ok, I have done some serious researching tonight on this topic. I was trying to find some sort of way to intercept menu tree data builds, but really can't find a "drupal" solution that allows alters to happen. After a while of searching, I found this module: http://drupal.org/project/menu_position

The module provides a plugin API that I think I might be able to hook into. Granted this means that for this type of functionality, Menu Views will require this additional module. I've gone ahead and committed some initial code to 7.x-2.x-dev. It doesn't actually do anything yet, however, but it's a start.

http://drupalcode.org/project/menu_views.git/commit/7db3645

geoffreyr’s picture

Looks like the code in menu_views_menu_position_rule_alter isn't unserializing the conditions array before trying to process it. Trying to insert the following before the line beginning
// Process Menu Views plugin in this rule.
should alleviate this:

  if (is_string($rule->conditions)) {
    $rule->conditions = unserialize($rule->conditions);
  }
lpalgarvio’s picture

this issue needs some attention :S

the module menu_trail_by_path doesn't helps in this case
http://drupal.org/project/menu_trail_by_path

markhalliwell’s picture

Status: Active » Closed (won't fix)

I'm going to have to mark this as "won't fix" as I do not have the time or real desire to implement this complex feature. If anyone wants to take this on, you may re-open this issue only if you have a patch provided.

f0ns’s picture

This can easily be fixed with Javascript if you really need this functionality in Menu Views (read out of URL & set active in menu)

seanr’s picture

Issue summary: View changes

f0ns, unfortunately, that won't help in cases like menu_block where you have a submenu that only shows when its items are in the active path. I've already got menu_position, so I'll check that out.