Hi to all

I have a problem with expanded-collapsed property in dhtml menu.

I have 3 menus structured in this way:

- Games
--game 1
--game 2

- Services
-- Service 1
-- Service 2

I set for the parent item (of each menu) Games and Services the propety "Collapsed".
So i have to see at the beginning only this two voices with possibility to click and open the entire menus.

But when i load the page that menus are all opened.

Looking in the code page I found this:

The css class for the parente element Games and Services are not:

  • Infact if I save the page in local and modify the css... the "collapsed feature" start to work correclty.

    Someone have idea about to solve?

    Thanks!

  • Comments

    Dret’s picture

    Ehm...sorry the code was not printed (and the menu are 2 and not 3!)

    The wrong code is:

    <li class="expanded dhtml-menu ative-trail ">

    Insted of:

    <li class="expanded dhtml-menu collapsed start-collapsed ">

    Thanks!

    yakker’s picture

    Me too - I want to have access to "collapsed" and "expanded" classes in my CSS, but they don't seem to be writing to the HTML. I'm new with AJAX, but it seems like the menus aren't actually making an http: request on-click, but rather assigning classes at load and just animating them. ???
    Love this functionality, though!

    cburschka’s picture

    I want to have access to "collapsed" and "expanded" classes in my CSS, but they don't seem to be writing to the HTML

    ...sorry, come again? What did you try to do, and how?

    the menus aren't actually making an http: request on-click

    You bet - loading this data on demand would be far too complex and slow to be worth it, since there's not a lot of it. The entire menu tree gets rendered, but is partially hidden. (Or should be, as this issue shows.)

    (For the record, "collapsed" is the class that sets the icon and tells Javascript that the menu is closed right now, while "start-collapsed" is the class that tells CSS to hide the submenus. This distinction is required because if the CSS rules were added to "collapsed" instead of the extra class "start-collapsed", then the CSS rule would instantly toggle the menu without a sliding animation.)

    Dret, if the menu item gets the class "active-trail" and not "collapsed start-collapsed", that is because the menu tree believes it is in the "active trail", meaning you are currently on a page listed in that menu, and the menu should therefore be expanded.

    If this is happening for multiple menus at once, then naturally there's a bug. I'm not sure what is causing it, but I'll experiment with this a bit. I assume you created these menus on "Administer -> Build -> Menus", and set them not to be "always expanded"?

    cburschka’s picture

    Title: Wrong classes for collapsed menu » Menu items in "active trail" when they should not be.

    Updated title to reflect diagnosis rather than symptom.

    yakker’s picture

    Apologies and thanks, Arancaytar.

    I managed to figure out that start-collapsed was what "closed" the menu, though I did not realize what "collapsed" actually did (not a lot of drupal-guts experience here). I wanted to be able to use CSS to change the look of a <li> based on having the tag "collapsed" or "expanded." To be honest, I can't completely remember why - my primary goal was to problem solve the issue where one of my DHTML menus, no matter what, displays as expanded on the front page regardless of its previous state on the page from which I navigated.

    delgiep’s picture

    Assigned: Unassigned » delgiep

    Hi Arancaytar this behavior happens when two menu item has the same address. If you change address link it works. I will sugest a patch on menu.inc to solve this.

    Duda.

    cburschka’s picture

    Status: Active » Closed (works as designed)

    Hi,

    If this is the only case when this happens, then that is by design of Drupal's core menu system. The only way Drupal can possibly know which menu item is active is by looking at the current page's path. If two items have the same path, then they will both be active.

    I don't think it's likely this can be changed in core, though you're welcome to suggest a patch. It definitely can't be changed in this module, since it takes the active trail as-is from core.

    delgiep’s picture

    Thanks Arancaytar. I open a ticket to menu module Drupal Core.