We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello there,
    Has anyone tried using the accordion menu http://wiki.modxcms.com/index.php/Accordion_menu_with_Wayfinder_using_JQuery
    with 3 levels deep?
    Thanks


      • 30564
      • 60 Posts
      In some respects I’m saying this so that either one of the real experts can shoot me down, or maybe give a final, or more precisely current, definitive answer on this.

      In my opinion, there is a limitation within Wayfinder [creating appropriately "id’d" or "classed" <ul>’s] that means that it does not appear to be possible to create a call which will accomplish 3 level [that is nested] accordions. In my view, though, it would be doable within Ditto using layered calls.

      However, I’d be happy to be proven [code and templates please] wrong.<br /><br />Regards<br />PS Just to state the obvious this is on no shape or form a criticism of Wayfinder, just an acceptance of a limiting factor.
        • 23956
        • 1 Posts
        This is exactly my question smiley
        If somebody actually did something like this? I would appreciate it a lot smiley
        TNX
          • 8425
          • 159 Posts
          fyi - I ended up using a tree view instead of accordion menu for multi-level. See http://www.dynamicdrive.com/dynamicindex1/treeview/index.htm


            • 3632
            • 22 Posts
            Just in case anyone else is looking for a solution for this it’s actually quite simple.

            The only Wayfinder template you need to modify is the $parentRowTpl one. We are adding the class ’header’ to all containers in the menu - i.e. all pages with children. We also don’t include the URL of the parent page as these pages just serve as clickable headers to expand the submenu.

            <li class="[+wf.classnames+]"><a class="header" href="#" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>
            


            In my own case I put that in a chunk called projects_menu_parent_row and this gave me the wayfinder call:

            [!Wayfinder?startId=`[[UltimateParent]]` &displayStart`false` &outerTpl=`OuterTpl` &innerTpl=`InnerTpl` &rowTpl=`RowTpl` &parentRowTpl =`projects_menu_parentrow` &innerRowTpl=`nnerRowTpl` &firstClass=`first` &hereClass=`here`!]
            


            The HTML generated by Wayfinder looks like:
            <ul id="ul_nav"><li class="first"><a style="outline: medium none;" class="header" href="#" title="Project Manaagement">Project Management</a><ul style="display: block;"><li class="first"><a class="header" href="#" title="Commercial Project Management">Commercial</a><ul style="display: block;"><li class="first"><a href="/projects/project-management/commercial/research_library_-boole_refurbishment" title="Boole Refurbishment ">Boole Refurbishment </a></li>
            <li><a href="/projects/project-management/commercial/brookfield_health_sciences_complex" title="Brookfield Complex">Brookfield Complex</a></li>
            <li><a href="/projects/project-management/commercial/western_gateway_building" title="Western Gateway ">Western Gateway </a></li>
            <li><a href="/projects/project-management/commercial/glucksman_art_gallery" title="Glucksman Gallery">Glucksman Gallery</a></li>
            <li><a href="/projects/project-management/commercial/mardyke_project" title="Mardyke Project">Mardyke Project</a></li>
            <li class="last"><a href="/projects/project-management/commercial/biosciences_extension" title="Biosciences Ext">Biosciences Ext</a></li>
            </ul></li>
            <li class="last"><a class="header" href="#" title="Residential Project Management">Residential</a><ul style="display: block;"><li class="first"><a href="/projects/project-management/residential/house_kinsale" title="House Kinsale">House Kinsale</a></li>
            
            <li><a href="/projects/project-management/residential/house_waterfall" title="House Waterfall" project2="">House Waterfall</a></li>
            <li class="last"><a href="/projects/project-management/residential/residence_ballyburden" title="Ballyburden House">Ballyburden House</a></li>
            </ul></li>
            </ul></li>
            <li class=""><a class="header" href="#" title="Grand Solutions">Grand Solutions</a><ul><li class="first"><a href="/projects/grand-solutions/duplicate-of-house-kinsale2" title="House Kinsale">House Kinsale</a></li>
            </ul></li>
            <li class=""><a class="header" href="#" title="Design & Build">Design & Build</a><ul><li class="first"><a href="/projects/design-build/house-kinsale-03" title="House Kinsale">House Kinsale</a></li>
            </ul></li>
            <li><a href="/projects/property-risk-management" title="Property Risk Management">Property Risk Management</a></li>
            
            <li class="last"><a href="/projects/engineering-consultancy" title="Engineering Consultancy">Engineering Consultancy</a></li>
            </ul>
            


            Note the class ’header’ added to our parent rows.

            Finally, the javascript:

            <script type="text/javascript">
            $(document).ready(function() {  
               	 $('#ul_nav a.header').click(function(e){  
                    e.preventDefault();	
            		$(this).css('outline','none'); 
            		$(this).next("ul").slideToggle(500);
            $(this).next('ul').children('li').children('ul').slideDown(500);
            //on the next line we use 'find' rather than 'children' as we want to contract all child UL elements
            		$(this).parent().siblings("li:has(ul)").find("ul").slideUp(500);
            	}); 
            });  
            </script>
            


            There will be a fully working version of this at Total Project Solutions Ireland in a few days.


              • 36446
              • 184 Posts
              @bluefrog.
              Your menu looks great but actually i can’t get the third level to show up with your advice here. Could you copy and paste all your menu chunks and stuff to this forum so we others could use your 3-level accordion as well? Would be great!
              ...

              now i got it showing the third level by just altering a setting in wfJS - i set "collapseprev: false" but now all the menu items stay expanded when clicked and are not closing when you click on another item... Maybe anyone has an idea how this could be solved? Any help would be highly appreciated!

              Update:
              okay i used this menu:
              http://www.kunane.com/modx/wayfinder-nested-accordion.html
              and now i think i’m satisfied smiley.
                https://www.beautyislife-shop.de - premium make-up!
                https://www.topsterne.de - sell it here!
                ---------------------------------------------------------