When you have both context and admin_menu modules enabled and you define a context with a menu condition the breadcrumb on /user and /admin/user/* is incorrectly set to
0 / 1 <img src="/achieve/sites/all/modules/admin_menu/images/icon_users.png" width="16" height="15" alt="Current anonymous / authenticated users" title="Current anonymous / authenticated users" />
Steps to reproduce:
- Install Drupal, Admin Menu, and Context
- Navigate to /admin/user/user (or access /user as an anonymous user)
- Verify that the breadcrumb is correct
- Create a context with a menu condition, select any menu entry
--Reaction selection doesn't matter and can be omitted still producing the same result - Navigate to /admin/user/user (or access /user as an anonymous user)
- Breadcrumb now displays:
0 / 1 <img src="/achieve/sites/all/modules/admin_menu/images/icon_users.png" width="16" height="15" alt="Current anonymous / authenticated users" title="Current anonymous / authenticated users" />
I've tested this on a clean Drupal 6.19 install with only Context 3.0, CTools 1.7, and Admin Menu 1.6 installed.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | modules_context_plugins_context_condition_menu.inc_.901606.patch | 2.38 KB | pillarsdotnet |
| #30 | context_condition_menu-901606-30.patch | 2.23 KB | zilverdistel |
| #19 | context_condition_menu-901606-19.patch | 2.18 KB | wojtha |
| #10 | context-menu-901606-10.patch | 2.22 KB | plach |
| #9 | context-menu-901606-9.patch | 2.09 KB | shawn_smiley |
Comments
Comment #1
shawn_smiley commentedI've narrowed down the source of the problem, but I'd like to get some feedback on the best way to solve it before creating a patch.
The issue is related to the following code in method execute() of plugins/context_condition_menu.inc:
Specifically, the line menu_set_active_menu_name().
When you have the admin_menu module installed, the query returns both the admin_menu and navigation menus as matching the path. Since the admin_menu entry comes up first, the code changes the active menu from navigation to admin_menu which in turns pulls the admin menu's modified menu content for the user paths which include an image.
The simplest fix would be to modify the query to include menu_name<>'admin_menu' in the query. But I'm not sure that is the best fix.
What does everyone else consider to be the best approach to resolving this?
One idea I have for a more flexible solution is to add an extra setting to the context settings screen that allows the user to select menus to exclude/ignore. Then modify the above code to look at this configuration setting and filter the menu list appropriately.
Comment #2
shawn_smiley commentedThe attached patch adds a new section to the Context UI Settings screen that allows the administrator to select which menu(s) to use when checking a menu context condition. The query in the execute() method is then modified to do an IN() search on the selected menus. The default is to include all menus.
Comment #3
shawn_smiley commentedComment #4
shawn_smiley commentedComment #5
plachComing from #909148: Arbitrary menu selection in menu condition with an alternative approach: the attached patch introduces an
'ORDER BY mlid ASC'clause to the query to give priority to menus having the older items.Comment #6
echoz commentedAfter installing Context and using a menu condition, not using breadcrumb (disabled or not in zen theme settings) I had the above as the h1 title (instead of "Users"), and plach's context-909148-1.patch resolved this. I haven't found any issues with it.
Comment #7
plachPerhaps we should merge the two patches: having an explicit choice as proposed in #2 seems to be the only way to get the needed results for every use case, while #5 provides a good way to have a consistent behavior when the result would be ambiguous.
Comment #8
echoz commentedI know this is still in progress, but wanted to report that while the patch from #5, context-909148-1.patch resolved the h1 on admin/user/user (as I reported in #6), the same problem appears for the h1 on admin/user/user/create.
Comment #9
shawn_smiley commentedHere is an updated patch that combines both my approach and plach's approach.
Comment #10
plachThe patch behaves well and fixes the issue. We should use the configured menus also when selecting the condition values, otherwise one could select a menu item that is not allowed by the current configuration. Moreover there were a couple of minor string issues. Here is a reroll.
Comment #11
mikebell_ commentedSubscribe
Comment #12
jmseigneur commentedUsing Context 6.x-3.0, applied patch #10, it solved /user but as reported above admin/user/user/create has still the problem. There is also another problem, the context menu condition works when it is in the main language (fr in this case) but it does not work for the menus in English. Any ideas?
Comment #13
jimmynash commentedDrupal 6.19, Context 6.x-3.0, Admin Menu 6.x-1.6
Same behavior. Using a context with a menu condition, /user, /admin/user/user and /admin/user/user/create all had the title set to the admin_menu image markup.
Applied patch in #10, it failed to apply from the module root and from the plugins directory, but I was probably doing something wrong. Applied it manually and the titles are back to normal on those user pages.
Have not found any residual issues from the patch.
Thanks!
Comment #14
mikebell_ commentedApplied patch from #10 manually against 3.0 and I still get the issue
Comment #15
plachDid you esclude "admin_menu" in the context general settings page?
Comment #16
jimmynash commentedUpdate to #13
I don't know if this is intended behavior or not for this condition, but before the patch, if a parent menu item was selected as the menu condition, all child menu items for that parent also triggered the condition. In my case this was desired behavior. If the client added child menu items to that parent the context persists. That way the context did not have to be edited to add that new child menu item after it was added to the menu tree.
After the patch this stopped happening. In order to get all child menu items to also trigger the context, we had to select the parent and all children in the condition.
It seems that there might be a typo in the patch.
Here is the patch addition to the execute function:
What I think was supposed to be there was:
I changed the variable for $items['href'] to $item['href'].
I would attach a new patch, but I still don't have that figured out yet.
Can anyone else confirm?
Comment #17
mikebell_ commentedRe #15 thank you, I excluded the menu and it works fine.
Comment #18
wojtha commented#949994: Title corrupted on login page marked as duplicate of this issue.
Comment #19
wojtha commentedRerolled patch from #10 as there is an error in the 3rd hunk so the patch from #10 can't be applied automatically.
Comment #20
henrijs.seso commentedpatch #19 good over here!
Comment #21
perandre commentedPatch in #19 did the trick.
Comment #22
henrijs.seso commentedthen
Comment #23
rasumo commentedPatch #19 works on /user and most other pages having the issue but I still get it on admin/user/user/list
Comment #24
joelstein commentedBy simply applying the patch at #19, user and admin/user/user worked fine.
But admin/user/user/create and admin/user/user/list didn't work until I saved my Menus setting at admin/build/context/settings. Specifically, I had to exclude the "admin_menu", and then it worked.
Does that mean this patch needs more work? Should the default value for "context_condition_menu_selections" exclude "admin_menu"?
Comment #25
wojtha commented@joelstein it is working as desired imo, it is not automatical fix
Read comment #2: "The attached patch adds a new section to the Context UI Settings screen that allows the administrator to select which menu(s) to use when checking a menu context condition."
Comment #26
iLLin commentedDo you think the same settings should be applied to the context_reaction_menu.inc when selecting the menu item or breadcrumb? I think if your going to limit your menus through the settings, it should reflect visually when setting up your context.
Comment #27
Anonymous (not verified) commentedBig thanks for the patch. #19 + changed settings worked for me.
Comment #28
eelkeblokSubscribing
Comment #29
mikebell_ commentedMy 2 cents - I think that it should be left on the settings page and not part of setting up your context. Especially for the amount of times it's going to be used it hardly warrants adding to the main bulk of context, unless I'm missing something fundamental.
Comment #30
zilverdistel commentedThe patch in #19 works for me.
Attached is the same patch, but I altered the description on the settings form to reflect that if "none are selected, all of the menus are used" as this better describes the implemented behaviour.
Setting the status of this issue to "needs review".
Comment #31
mstrelan commentedI can confirm that #30 fixes the issue when you go to /user. If then you also deselect "admin menu" in the context settings it also fixes it for /admin/user/user/list and /admin/user/user/create. I think this needs to be documented somewhere, perhaps when you go to the context settings page it could say something like "admin menu has been detected, in most cases we recommend deselecting admin menu".
As for #26 perhaps when you add a menu reaction and you have admin menu installed it but not deselected it could show a message there too saying that this may interfere on the user page.
Comment #32
pillarsdotnet commentedComment #33
pillarsdotnet commentedPatch no longer applies; re-rolled.
Comment #34
andrew.lansdowne commentedFor other users wanting a clean workaround while this is fixed, I have put this into my theme_preprocess_page function, something similar may sort it for you:
Comment #35
heddiw commentedSubscribing
Comment #36
Sarenc commentedThanks, #33 works for me.
Comment #37
niklp commentedI wonder if #23 and #34 (and maybe #37) in this thread would be of help? http://drupal.org/node/279767
Seems that if you don't correctly doctor your menu query, you could end up with one of several entries for the same path. One needs to be careful that a) we have permission for the path and b) the path is created by a specific module (to ensure it's unique).
SELECT mlid FROM {menu_links} WHERE link_path = 'admin/user/user';in my site gives me THREE mlid's.SELECT mlid FROM {menu_links} WHERE module = 'system' AND link_path = 'admin/user/user';gives me only one.This method would work exclusively(? I think), if it were not for the fact(? I think) that even the original system module entry for that path could be modified, although it's pretty unlikely. Excuse the doubts, but that's what info I have anyway! :)
Comment #38
nicholas.alipaz commented#33 working on latest dev as of today.
Comment #39
TimG1 commented#33 working on latest dev as of today for me too.
Thanks!
-Tim
Comment #40
henrijs.seso commentedthen
Comment #41
blb commentedI tried #33 with the current dev and it didn't fix the problem.Patch at #33 on current dev did work after all.
Note that it is necessary to clear cache to see the result. I apologize for being either hasty or sloppy before. Thanks for the fix.
Comment #42
niklp commented@bib you're going to have to leave more info than that if you want to help fix the issue - do you have any feedback?
Comment #43
nikosnikos commented#33 worked for me too on last dev. Thanks !
Comment #44
niklp commentedIs it just me or does this seem a very "hard work" approach to fixing the issue? Is the information in #37 of no use...? Seems like altering the query in the first place would fix this issue, or does that have a level of ambiguity that can only be circumvented by the technique in patch @ #33?
Comment #45
niklp commentedFYI patch works as advertised from #33. Gonna just leave it at that for now! :p
Comment #46
hefox commentedhttp://drupalcode.org/project/context.git/commit/3695e17