in the excellent MODx Wayfinder e-book by kongondo is a featured jQuery Accordion which uses a nice jQuery plugin by www.i-marco.nl.
Yesterday i found out, that the original plugin code has been updated, which now also allows nested accordions, as well as the support of panels (e.g. a div within the menu structure).
you can check the demos here: accordion demos
playing around with it, i managed to integrate the nested version in MODx which i will describe here.
2. extract the files and upload jquery-1.4.2.min.js & menu.js to your templates folder and reference both files in the header of your template. If you are already using jQuery on your site (check if your version is compatible), you only need to upload menu.js
3. i altered the styles.css files a bit to my needs, so either use the file from the downloaded .zip, or use mine, which you can download here. Reference it in your header, too.
// You can also integrate it in your other already existing stylesheets.
btw. this is how our nested accordion will look like:
4. create a Chunk "acc-folder" with the following code:
<li[+wf.classes+]> <a title="[+wf.title+]" href="#">[+wf.linktext+] »</a> [+wf.wrapper+] </li>
5. and another Chunk "acc-inner":
<ul class="acitem"> [+wf.wrapper+] </ul>
6. Ressources that will be containers/folders in your menu, either need to have the "Link Attributes" field set to rel="category", or the template set to "blank":
7. finally place the Wayfinder call in your template:
[[Wayfinder? &startId=`0` &outerClass=`menu` &hereClass=`expand` &selfClass=`active` &categoryFoldersTpl=`acc-folder` &innerTpl=`acc-inner`]]
ta-daaa ... i guess that's it!
/////// *added*
to toggle the accordions (closing on a second click) do the following:
replace &outerClass=`menu` in your wayfinder call with &outerTpl=`acc-outer` and create a new chunk "acc-outer":
<ul class="menu collapsible"> [+wf.wrapper+] </ul>
and change the already existing chunk "acc-inner" to:
<ul class="acitem collapsible"> [+wf.wrapper+] </ul>
- Required fields are marked with *.