? Success

User tests: Successful: Unsuccessful:

avatar simplysites
simplysites
28 Jul 2015

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.

avatar simplysites simplysites - open - 28 Jul 2015
avatar simplysites simplysites - change - 28 Jul 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Jul 2015
Labels Added: ?
avatar photodude
photodude - comment - 28 Jul 2015

Can you explain how this is different from, or an improvement over, the existing implementation of the current and active css classes in the menu?

avatar fruppel
fruppel - comment - 28 Jul 2015

I think it's the same as the already existing class "active"

avatar simplysites
simplysites - comment - 28 Jul 2015

If the “active” class is the same, then how come it does not appear where it should ?

avatar photodude
photodude - comment - 28 Jul 2015

Maybe there is a bug in the implementation of the active css class that is being over looked.

avatar simplysites
simplysites - comment - 28 Jul 2015

I’ll check and get back to you

avatar fruppel
fruppel - comment - 28 Jul 2015

I made a quick test. For me it's working in 3.4.3.

avatar fruppel
fruppel - comment - 28 Jul 2015

image

avatar simplysites
simplysites - comment - 28 Jul 2015

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.

avatar Fedik
Fedik - comment - 28 Jul 2015

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

avatar simplysites
simplysites - comment - 28 Jul 2015

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.

menumodule
menucode

avatar fruppel
fruppel - comment - 28 Jul 2015

What happens if you set "Base Item" to "Current" in your module config?

avatar simplysites
simplysites - comment - 28 Jul 2015

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 ?

screenshot

avatar fruppel
fruppel - comment - 28 Jul 2015

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.

avatar simplysites
simplysites - comment - 28 Jul 2015

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.

avatar fruppel
fruppel - comment - 28 Jul 2015

Had a quick look at it. I think a menu structure like this:

Home

  • Ondernemen
    • Ruimte

...
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.

avatar simplysites
simplysites - comment - 28 Jul 2015

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.

avatar fruppel
fruppel - comment - 28 Jul 2015

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.

avatar fruppel
fruppel - comment - 28 Jul 2015

Just to make it clear:

  • Top menu
    • Home
    • Nieuws
    • Contact
  • Main menu
    • Ondernemen

AFAIK with this structure it is impossible to make "Home" as parent active item for "Ondernemen"

avatar Fedik
Fedik - comment - 28 Jul 2015

@fruppel just split it to 2 real menus (Topmenu and Mainmenu), instead of use such strange structure :wink:

avatar fruppel
fruppel - comment - 28 Jul 2015

I think I see the problem now, sorry took me a little bit longer :D

If you have a menu like this:

  • Level 1
    • Level 2
      • Level 3

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

avatar simplysites
simplysites - comment - 28 Jul 2015

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 ?

avatar brianteeman brianteeman - change - 28 Jul 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-07-28 17:38:32
Closed_By brianteeman
avatar brianteeman brianteeman - close - 28 Jul 2015

Add a Comment

Login with GitHub to post a comment