Hi, not entirely sure of the feasibility of this one, but I thought I'd throw it up here to see if there's any interest (and it'd certainly help me out). Ideally I'd like to be able to set a context condition that would fire whenever a node with a entry under a particular menu is viewed. That is to say, if I have the following menu structure...
[primary-links]
- Item 1
-- Item 1.1
-- Item 1.2
- Item 2
- Item 3
[another-menu]
- Item 1
- Item 2
-- Item 2.1
-- Item 2.2
... I'd like to set a condition on the entirety of [primary-menu] or [another-menu] or what have you. Obviously I could select every item under the particular menu with the current Context UI but this would fall down when new items are added to the menu. Does that all make sense? Comments/questions?
Comments
Comment #1
steven jones commentedInteresting, but the actual drupal menu trail doesn't include the menu either.
Comment #2
nauthiz693 commentedExactly what I'm looking to do too.. Did you figure out another way to do this?
Comment #3
terrencewood commentedHere's a module that set's a context based on the menu the current item belongs to.
context_active_menu.info
context_active_menu.module
plugins/context_condition_active_menu.inc
Comment #4
steven jones commentedOne for context 3.x
Comment #5
DjebbZ commentedI'm using context 3.0-beta4 on the last Drupal (6.16).
I don't know if the plugin is not working, or if I didn't understand it. Here's what I'm doing with it :
In my primary menu, I want all menu item under one of them (including the selected menu item itself) to set the condition. Which means, all content in the menu trail should activate the condition and trigger the necessary reaction, which is "display a menu_block in the left region".
Is this what this plugin does ? Because I have no difference in the condition setter in the Context UI, and no different effect : my left block does not appear at all.
Note that I also tried to activate the Menu Trails module, but it's not working either.
Any idea how to achieve this ?
Comment #6
steven jones commentedLets leave it on the context 3.x branch then.
Comment #7
terrencewood commentedThe context_active_menu plugin takes the entire menu from the root so you can set the context if a menu item is a selected menu. e.g. primary-links .
What you are after setting a context when a menu item is in a subtree. See the context_active_menu_tree plugin below
Comment #8
terrencewood commentedModule to set a context if the current menu item is in a subtree
context_active_menu_tree.info
context_active_menu_tree.module
plugins/context_condition_active_menu_tree.inc
Comment #9
alanburke commentedI needed to get this working for Context 2.
Patch takes the ideas in the preceding pasted-in module, and puts it into the context module itself.
This is how I was expecting the behavior of this particular context to function.
My code is a bit rough, to say the least, but it works for my particular use case.
Comment #10
yhahn commentedOn my list.
Comment #11
yhahn commentedI believe this is resolved by the fix in #791862: menu_get_active_menu_name on some pages returns "navigation" improperly, causing context to fail.
Comment #12
millenniumtree#8 appears to be in context now, but #3 is NOT!!!
We needed to activate a context if any page/view/etc in a particular menu was being viewed.
#3 works great EXCEPT if you've linked to a Views page.
I've modified the plugin include code to work with both node and Views pages.
The only line you have to change is the $menu= line in the execute() function. Search for the link_path instead of the link_title
plugins/context_condition_active_menu.inc
The real question is this: Why is this not already in Context??
Comment #13
davidseth commentedI have upgraded this great module to D7. If anyone is interested I can put it into a sandbox. I would also like to get this as a full module. @terrencewood what do you think?
Cheers,
David
Comment #14
davidseth commentedI have created a sandbox project for D7: http://drupal.org/sandbox/davidseth/1541422