View Full Version : Current state in Glossy Accordion Menu

08-25-2008, 08:05 PM
1) Script Title: Glossy Accordion Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-glossy.htm

3) Describe problem: First of all, fantastic script. I've customized the CSS to visually match my page, but there is one feature I wish it had, a current state. An example menu:

Parent A
- child 1A
- child 2A
Parent B
- child 1B
- child 2B

What I am looking for is help adjusting the script so that if you clicked "child 1B" you would be taken to that page and the accordion would remain expanded and the "child 1B" link highlighted letting the viewer know which section they are in. Is this possible?

08-26-2008, 04:11 AM
There's no easy way to do this using JavaScript actually. Such functionality is usually done on the server side, by dynamically matching the current page's URL with a particular menu item within the menu, then generating the appropriate HTML to "select" it. The tricky part is the matching itself.

The script does let you have a certain menu item expanded depending on the page the menu is on, but this does mean you have to modify the menu item links with a URL parameter, such as:

<li><a href="target.htm?mypets=1">My pets (2nd header expanded by default)</a></li>

More info here (http://www.dynamicdrive.com/dynamicindex17/ddaccordion_suppliment.htm). But again, this doesn't take care of "highlighting" the selected menu item itself, which can really only be done reliably on the server side.

11-02-2008, 02:21 AM
I think the first post, like myself, just needs a function to pass an index number to in order to highlight a specific menu item, whether header or sub-header. A typical menu will have some sub-headers but some menu items will be just 1 level with no submenus. The link called can pass the identifier to the next page so then we know what to highlight. Why is this not possible? Don't you think it's a good feature for the menu to indicate which page is currently viewed? I love your script but I need that visual cue.

Thank you

11-02-2008, 08:26 PM
The URL parameter feature by default only works on the headers themselves in highlighting a specific header (and not a link within the sub menu content), since the sub menu content technically is just some arbitrary content that the headers expand/ contract, and can contain a whole bunch of things other than menu links. It's certainly possible to modify the feature to also highlight a certain link within the sub menu content, but some "rules" need to be established to let the script know which links are menu links, and which aren't, inside the sub menu content.

I'll consider adding the above feature the next time the script is updated.