PDA

View Full Version : accordion menu and linkable headers (again)



gargiulo
02-11-2009, 01:41 PM
1) Script Title: accordion menu bullet

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

3) Describe problem: I would like to open the related link when clicking an header.

The result should be:
- the target page will open
- the accordion menu on the target page (the accordion menu is saved in a PHP include across all my pages) will open the related header and discover all subheaders.

It seems you can do something similar using optional 'onopenclose:function', but how can I do this with simple link? the tutorial on the dd page show how to open an IFRAME but I would like to do something simpler: open a link.

Just in case you're wondering why to do this:
imagine you have a product catalog with all products orgnized by category and then by subcategory. The first ddaccordion menu will show all categories. When you expand a category you will see all subcategories related to that category. In the same time a new page will open showing the accordion menu (with cklicked category expanded); please note the accordion menu is included on all pages by using a php include funtion. The same page will show all subcategories.
You click a subcategory in the accordion menu or a subcategory on the page and you are redirected to another page.

I've read a lot about this problem but I've not found a valid solution yet.

Any idea?

Thanks in advance.

gargiulo

jscheuer1
02-11-2009, 03:39 PM
You don't really need to modify the script much, you may use the method outlined here to get the header links to open their respective pages:

http://www.dynamicdrive.com/forums/showpost.php?p=184355&postcount=9

To get the menu on the 'receiving' page to open, you may use:


persiststate: true,

in the ddaccordion.init function, but I believe that will be a little unreliable in some cases. What I would suggest is, to be sure - go ahead and use an include, but use separate ddaccordion.init functions for each page. Set:


persiststate: false,

except on the home page (unless you want default expanded on it too). Set each 'receiving' page's, ex:


defaultexpanded: [0],

to the menu you want expanded on it, using the number of the header to expand (numbers start at 0 for the first one). Set all page's:


collapseprev: true,

Finally, if relying on persistence to get the home page to display the last 'receiving' page's menu expanded, make this one small modification to the ddaccordion.js file (comment out (red) the two highlighted lines as shown near the end of that file):


$('.'+config["contentclass"]+":visible").each(function(index){ //get indices of expanded headers
expandedindices.push($(this).attr('contentindex'))
})
// if (config.persiststate==true){ //persist state?
expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
ddaccordion.setCookie(config.headerclass, expandedindices)
// }
})
})
}
}

sailorkid
02-11-2009, 09:51 PM
I am having the same issue. I want the menu header bars to link to distinct pages to improve the user experience. Where does this refernced code go? http://www.dynamicdrive.com/forums/showpost.php?p=184355&postcount=9

jscheuer1
02-12-2009, 12:39 AM
I am having the same issue. I want the menu header bars to link to distinct pages to improve the user experience. Where does this refernced code go? http://www.dynamicdrive.com/forums/s...55&postcount=9

In the future, please start a new thread rather than add onto a unresolved or a resolved thread. You may always reference any and all threads that you are referring to by linking to them.

Anyways, the safest place would be just before your page's closing </body> tag. However, anywhere after the (last) ddaccordion.init script(s) on your page(s).