Active
Project:
Menu Position
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Dec 2011 at 09:59 UTC
Updated:
22 Jan 2015 at 23:21 UTC
Jump to comment: Most recent
Used with the Menu block module, a parent menu item of a menu position rule show as "expanded" when it is active. It is confusing since there is no visible child items. It should show as "leaf".

Also, when the setting is mark the rule's parent item as being "active", the parent item should show as "leaf" too.

| Comment | File | Size | Author |
|---|---|---|---|
| screenshot3.png | 40.96 KB | C. Lee | |
| screenshot1.png | 29.45 KB | C. Lee |
Comments
Comment #1
C. Lee commentedYou can reproduce this bug with Drupal 7.9, Menu block 7.x-2.x-dev, and Menu position 7.x-2.x-dev.
Comment #2
m4oliveiI'm also seeing this issue. I think the rule should be that if the only child of the menu item is the menu position rule, the parent should show as a leaf.
Comment #3
m4oliveiThe issue may be beyond the grasp of menu_position, at least in its current state. Menu position adds an actual menu item for each menu postion rule to the Drupal menu system, which is what causes the parent item of a menu position rule to actually be rendered as a parent instead of a leaf.
Anyone have any suggestions for how we can render the parent item of a menu position rule as a leaf when its only children are the menu position rule?
Comment #4
m4oliveiFor anyone struggling with the same issue, the way that I worked around this issue, which works quite nice in my use case, was to override theme_menu_link():
This simple theme override catches the case where the only child is a menu position rule, simply by removing the 'expanded' CSS class that is present even when
$element['below'] == FALSEComment #5
johnalbinYep. This is a known bug in menu_block module actually. Since I'm the maintainer of both modules, we can keep this issue open here until I get that fixed.
Comment #6
Bernsch commentedWhen you would show "leaf" in class attribut:
in #4 add this rows:
...
if ($class == 'expanded') {
unset($element['#attributes']['class'][$key]);
+ $element['#attributes']['class'][] = 'leaf';.
}
...
...
else if ($element['#attributes']['class'] == 'expanded') {
unset($element['#attributes']['class']);
+ $element['#attributes']['class'][] = 'leaf';
}
...
Comment #7
Bernsch commentedComment #8
andrewko commentedSince this is a known menu_block bug, is there a issue number we can link to in menu_block to cross-reference these two?
Comment #9
Anonymous (not verified) commentedThe workaround from #4 doesn't add 'leaf' as a class (as #6 pointed out), so here's an updated and slightly simplified override of theme_menu_link() that does:
Here, instead of removing the 'expanded' class then adding the 'leaf' class, we just replace one with the other.
Comment #10
Bernsch commentedComment #11
mstrelan commentedWorkaround in #9 appears to do the trick, but since there is no patch I'm setting it back to Active.