We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27449
    • 211 Posts
    I see this example wayfinder menu : http://wiki.modxcms.com/index.php/Accordion_menu_with_Wayfinder_using_JQuery

    I create all chuncks and doesn’t work?
    what did I wrong?
      • 7231
      • 4,205 Posts
      Did you upload the javascript files to your server?

      <link rel="stylesheet" type="text/css" href="assets/css/accordion-menu.css" />
      <script type="text/javascript" src="assets/js/jquery-1.2.2.pack.js"></script>
      <script type="text/javascript" src="assets/js/ddaccordion.js"></script>

        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27449
        • 211 Posts
        yes, but I have a question...
        which is content accordion-menu.css file? It’s equal chunck wfStyle?
        I’m using the same code for the file accordion-menu.css.
          • 7231
          • 4,205 Posts
          they are the same. You could either use it as a chunk as in wfStyle or you can add it in to the template header directly. The same is true of the wfJs file.

          Check out this page at DynamicDrive.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 27449
            • 211 Posts
            I don’t know what’s happen but my menu show all the submenu without click
            I can not put the menu to work sad
              • 14147
              • 26 Posts
              I am having the same trouble. One thing I did notice is that the version of Jquery on that site is greater than that given 1.2.6 versus 1.2.2. However even altering the script file name to reflect the latest version of JQuery, I still could not get it to work.

              <script type="text/javascript" src="assets/js/jquery-[b]1.2.6.[/b]pack.js"></script>
              <script type="text/javascript" src="assets/js/ddaccordion.js"></script>


              I have reverted by to using the accordion menu and scriptalious, but still having problems...
                • 14147
                • 26 Posts
                Right, I’ve finally got a decent working version of accordion using jQuery, and without a whole host of code listed in the versions given on here. No doubt they are probably more featured than mine, but I’ve got mine working!

                Firstly, go to the jquery website and download the latest version (1.2.6) of the packed library and copy it into the directory: /manager/media/script.

                In the template of where you want the accordion menu to appear, or you can use the wfJS chunk, enter the code:
                                <script type="text/javascript" src="/manager/media/script/jquery-1.2.6.pack.js"></script>
                		
                		<script type="text/javascript">
                	
                                        // The line below makes sure that jQuery does not conflict with any other plugins.
                                        jQuery.noConflict();
                
                                        // This function is called when the document is loaded and displayed in the browser.
                                        jQuery(document).ready(function(){
                
                				// Add a value to each menu:
                				jQuery("#Menu > li > a + ul").attr("slide", "down");
                	
                				// Collapse everything but the first menu:
                				jQuery("#Menu > li > a").not(":first").find("+ ul").slideUp(1).attr("slide", "up");
                	
                				// Expand or collapse:
                				jQuery("#Menu > li > a").click(function() {
                					jQuery(this).next('ul').slideDown('fast');
                					jQuery(this).parent().siblings('li').find('ul:visible').slideUp('fast');
                				});
                			});
                		</script>
                


                The code is quite neat and does not require any more individual javascript function calls in the TPL files (such as onClick events).

                You need a minimum of three TPL chunks for the desired effect, innerTPL, outerTPL and parentTPL. The outerTPL defines the menu for having the accordion effect, the innerTPL stops wayfinder assigning the same template of outerTPL, and the parentTPL prevents the page reloading when a menu item is clicked.

                Create a chunk called innerTPL and copy the code below into it.
                <ul>[+wf.wrapper+]</ul>
                


                Create a chunk called outerTPL and copy the code below into it.
                <ul id="Menu"[+wf.classes+]>
                	[+wf.wrapper+]
                </ul>
                

                You’ll notice that the ID of the outer most UL is called "Menu", if this is changed, then in the javascript lines you’ll need to change the Menu as well.

                Create a chunck called outerTPL and copy the code below into it.
                <li[+wf.classes+]>
                	<a href="javascript:;" title="[+wf.title+]">[+wf.linktext+]»</a>
                	[+wf.wrapper+]
                </li>
                

                The blank javascript in the href is simply to prevent the page from reloading.


                The call to wayfinder is:
                [!Wayfinder? &startId=`0` &level=`2` &outerTpl=`wfOuter` &innerTpl=`wfInner` &parentRowTpl=`wfParentRow`  !]
                


                Hopes this helps anyone trying to get a simple accordion menu on their site.

                If you want to view an example of this accordion menu, go to the site http://www.dgpanthers.net
                  • 26849
                  • 16 Posts
                  Implementing this "lite" menu (which incidentally, is great!) it seems to collapse the menu each time a submenu item is clicked. How do you get an active expanded menu to persist in an expanded state? Is there something missing from the code?

                  Many thanks.