hello.
With Context menu you can set menu items to "active". This does not work for me in a menu_block.
I have Three levels of Primary Links, and secondary Links is set to come from primary. I print out the primary and secodary (second lvl from primary) in my theme and the third llv by menu_block. When I set a menu item active with "Context" Module, it will only show primary and secondary menu. In primary and secondary the menu items get "active-trail" style. The block is not printed.
I hope you understand what I try to explain. Is this a bug in the module or am I doing something wrong?
THX in advance.
Comment | File | Size | Author |
---|---|---|---|
#7 | mbcontext.tgz | 1.6 KB | NikLP |
#4 | menu_block_context.tgz | 1.26 KB | NikLP |
Comments
Comment #1
nauthiz693 CreditAttribution: nauthiz693 commentedI had the same problem.. I fixed it by creating a module with the following code:
I should probably create and submit a module that does the above, but I don't have time / motivation to go through the rigamarole.
Just create a module, and replace MODULENAME with the name of your module.
Comment #2
JThan CreditAttribution: JThan commentedWow, thx. I will definitly try this.
Comment #3
NikLP CreditAttribution: NikLP commentedWill this fix the issue where when the active menu is set with context, unless the *actual menu* item that is set to trigger the block is active, no block is shown?
ie secondary menu item block shows up on "aar" but not on "aar/groups" ? Is that what this is about? Didn't quite follow the initial post...
Comment #4
NikLP CreditAttribution: NikLP commentedI have had success with this module, and attached is a version with module folder, info file and dependencies sorted out. Hope it helps someone.
I've only tested it with showing the children of primary menu items in one block.
Comment #5
BrightBold@NikLP -
That functionality is exactly what I was looking for, but when I enabled your module I got the following error:
Fatal error: Call to undefined function context_active_values() in .../sites/all/modules/menu_block_context/menu_block_context.module on line 18
Let me know if I can provide you with any additional information that will help troubleshoot.
Comment #6
NikLP CreditAttribution: NikLP commentedHmm... this is likely caused by the include on line 17. Suggest you try removing line 17 and replacing with the following - it's probably not finding the required context module include as you likely have it in a different location to the one that is (incorrectly) hard coded into this module.
Comment #7
NikLP CreditAttribution: NikLP commentedHere's a slightly improved version of the module with better code style and the hard coded module directory taken out.
Comment #8
Mark TrappThanks for this: it works perfectly, with one caveat. Let's say you have a menu block that is linked to the following menu:
Item 1
- Subitem 1
Item 2
Item 3
Item 4
And you set up a context reaction to set "Subitem 1" as the active menu item. Unless "Expand all children of this tree" is checked in the block's configuration, the 'below' array in the menu tree is never populated for "Item 1" and thus, the menu item is never matched.
This could have implications for people who don't want to expand out the entire menu, and likely could be solved with a different matching algorithm, but the solution here works great outside of that problem.
Comment #9
Mark TrappAlso, context_active_values() doesn't exist in Context 3, so you need to define the active paths a different way. Based on the solution in #15 from #586396: Context Active menu problem, I replicated the function as such:
There may be a conflict with Context Contrib 3 as well, but I haven't isolated whether it's actually a conflict or a general problem with Context Contrib 3 yet.
If you guys are cool with it, I can wrap up these modules and my additions into a project on Drupal Contrib and maintain it so you guys don't have to. I'd like to explore how to get around the "Expand all children of this tree" requirement in the future anyway.
Comment #10
nauthiz693 CreditAttribution: nauthiz693 commentedYeah of course, that'd be awesome. I'd do it myself, but I'm going to law school in a couple months, so I don't think I'd be able to maintain it :-) That's why the drupal community (and open source in general) is so great.
Comment #11
BrightBold@amorfati - will you post in this issue to let us know if you release a contrib version? This would be a really useful module.
Comment #12
Mark Trapp@BrightBold: done and done.
I just released Context: Menu Block, which contains the code here, a few bug fixes, and a Context 3 release. If you're running Context 2, use the 6.x-2.x branch; otherwise use 6.x-3.x. Bad Things™ happen when you mix the versions due to Context's API change.
Let me know if there's any problems using it.
Comment #14
nauthiz693 CreditAttribution: nauthiz693 commented@amorfati - Sweet, works brilliantly. Thanks for maintaining this!
Comment #15
jedihe CreditAttribution: jedihe commented[Sorry for waking this up, but I think this can be useful for someone trying to solve this problem]
I think a better fit for getting menu blocks to behave this way is by using Menu Position. Although it does not have so much conditions as context, the integration with menu block seems to be complete; also, it is possible to write plugins... so maybe it could have many types of conditions as in context.
Comment #16
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedThank you so much the Menu Position module saved my day !