User tests: Successful: Unsuccessful:
Much like in Drupal (where the class is called "active-trail"), this marks each displayed menu item in the menu tree towards the active item with a specific class "current-trail". This unleashes a lot of easy CSS possibilities for menu styling that were previously not possible.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
I think it's the same as the already existing class "active"
If the “active” class is the same, then how come it does not appear where it should ?
Maybe there is a bug in the implementation of the active
css class that is being over looked.
I’ll check and get back to you
I made a quick test. For me it's working in 3.4.3.
The $path array in my testing environment always contains only the top level menu item, in my case
array(1) {
[0]=>
string(3) "107"
}
No deeper menu items are available in this array, and thus they are not marked with the class since all menu items are checked against this array. Hence, there could indeed be a problem there.
Looking at the definition of the $path array in modules/mod_menu/mod_menu.php, it is defined as
$path = $base->tree;
So the path will only contain the tree of the base item of the menu module and nothing deeper.
@fruppel: if we are looking at the same code base, how do you explain your example ?
I have to mention at this point that I am using a module which only represents a partial menu, not a complete one. Maybe there the bug is introduced.
sorry, I think something wrong with current pull ... class active
always works, at least for me.
can you please explain more detail about your problem, what you tries to fix here?
would be good to see some example of the menu structure, and menu module configuration?
so other can test/help you more here
Menu module settings and generated code (with my patch included): the new class "current-trail" is correctly labeling the menu structure, the "active" class is not. This is not the first occasion where I run into this problem, but it is the first one where I actually must rely on it heavily for styling.
What happens if you set "Base Item" to "Current" in your module config?
OK, now the active class appears correctly. Only problem is that now the module does not appear as it should anymore.
The home page is in another module, see screenshot of the correct version. So when going to the home page, the main menu disappears since the current item is no longer in the module scope.
Am I wrong to assume that my code should replace the $path check for the "active" class to allow this scenario ?
Could you show your menu structure please? Do you have two seperate menus? Then maybe "Current" is not the right option here. Which menu is disappearing? I am not saying that your approach is wrong, just trying to help and figuring out if it's a real bug.
I can do better: I have set up a cloned test environment on http://test.orb.simplysites.be.
SU access: username "super", password "Us3r!2015".
Test environment will be removed as soon as it is no longer needed.
Had a quick look at it. I think a menu structure like this:
Home
...
Nieuws
Contact
would make your life easier. In your top menu you could show only level 1 - 1. No need to have items like "Top menu" or "Main menu" in your menu structure.
That would put all top level items in the top menu as well as in the main menu, which is obviously not what I want.
Fact of the matter is that the "active" class starts acting strange when the base item is not set to "current". For me this is an error which should be fixed, either by using my solution (on the "active" class instead then) or using something else that allows the class to propagate nicely through the menu.
No it wouldn't. Set the top menu module to only show level 1. Set the main menu module to show only items from level 2.
Just to make it clear:
AFAIK with this structure it is impossible to make "Home" as parent active item for "Ondernemen"
I think I see the problem now, sorry took me a little bit longer :D
If you have a menu like this:
and in your model you set the config to Base Item -> "Level 1", Start Level -> 2 the "active" class is not applied to the menu items
@Fedik yes that would be an option too. But I am starting to think that there might be a real issue
Yes that's it !
I used your example (which I also understood after a few attempts) and it works correctly then. I'll use this since it is a bit more elegant indeed.
Nevertheless, the "active" class is not working correctly as you describe in this general situation.
Drop this change and make a bug report ?
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-07-28 17:38:32 |
Closed_By | ⇒ | brianteeman |
Can you explain how this is different from, or an improvement over, the existing implementation of the
current
andactive
css classes in the menu?