We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    So - the Structure of the site is roughly:

    startID=0 -> index - folder1 - folder2 - folder3 - ...

    did I understand you right that I have to put the Start page (index, the page with the error message) into a folder for the menu to work propperly (resp. put another menu to the start page)?
      • 7923
      • 4,213 Posts
      Yes, every page should be in a folder with this menu.. so it needs to be something like:

      Your Site
      |
      |-- folder1
      | |-- index (this document id is in site start configuration setting)
      | |-- document2
      | |-- document3
      |
      |-- folder2
      | |-- document1
      | |-- document2
      | |-- document3
      |
      |-- folder3
      |-- document1
      |-- document2
      |-- document3

      Currently the tutorial codes only work with single level menus.. but it would be possible ofcourse to make it work for multiple levels, eg the stuff in the folders would list like normal unordered list. Altough, It would not be possible straight away with wayfinder, because the first level items would need to be templated differently than others.. dunno if it’s possible to call another wayfinder in wayfinder’s template chunk.. that way it could be done without modifying wayfinder itself.. or it could be done by changing the javascript code..


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 14412
        • 74 Posts
        The example in the MODx wiki post on accordion menu with Wayfinder didn’t work for me, so i explored a bit and came up with an alternative solution that uses each menu row’s unique id and some classes to identify which menus to open/close. I like this solution better because:

        • it uses standard unordered lists (no divs)
        • works with menu items that aren’t folders (weblinks included)
        • theoretically, it is extendable to menus over 2 levels deeps, though the js needs some tweaking so the accordion effect on deeper menus doesn’t collide with the top menu one - Help needed on this
        • on the whole it seems more understandable to us mere mortals - no offense doze grin
        The js code is pretty ugly and certainly needs cleanup. Besides, I guess it would be better to use mootools/moofx (smaller size), but that’s a bit out of my league for now...This method does have a problem with IE (slight flickering when animating the effect) that I tried to solve with an init() function - to no avail (it works with FF2.0 tough).
        Now for what really matters, the code:

        MENU LAYOUT CHUNKS:
        wfOuter:
        [tt]<ul id="mainMenu">[+wf.wrapper+]</ul>[/tt]
        wfRow:
        [tt]<li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]" onclick="accordion(’nomenu’)">[+wf.linktext+]</a>
        [+wf.wrapper+]</li>[/tt]
        wfparentRow:
        [tt]<li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]" onclick="accordion(’menu-[+wf.docid+]’)">[+wf.linktext+]</a>
        <ul id="menu-[+wf.docid+]">[+wf.wrapper+]</ul></li>[/tt]
        wfInner:
        [tt][+wf.wrapper+][/tt]
        wfInnerRow:
        [tt]<li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>[/tt]

        JAVASCRIPT CHUNK (includes prototype and scriptaculous calls, remove them if already called elsewhere on page template)
        wfJs:
        <script type="text/javascript" src="[(base_url)]manager/media/script/scriptaculous/prototype.js"></script>
        <script type="text/javascript" src="[(base_url)]manager/media/script/scriptaculous/scriptaculous.js"></script>
        <script type="text/javascript">
        function closeVisible() {
        	var mmenu = document.getElementById('mainMenu');
        	var mheads = mmenu.getElementsByTagName('li');
        	for (i = 0; i < mheads.length; i++) {
        		if (mheads[i].className == 'hasmenu active'){
        			var smenu = mheads[i].getElementsByTagName('ul')[0];
        			new Effect.BlindUp(smenu.id, {duration: 0.2});
        		}
        	}		
        }
        
        function accordion(selected) {
        	if (selected == 'nomenu'){ //if user clicks menu row with no child menu
        		closeVisible(); //close visible menu
        		return;
        	}
        	else {
        		if (document.getElementById(selected).parentNode.className == 'hasmenu active') {
        			return; //if user clicks menu row which is already opened, do nothing
        		}
        		else { //if user clicks any other row that has a sub menu
        		closeVisible(); //close opened menu
        		new Effect.BlindDown(selected, {duration: 0.2});//open respective menu
        		}
        	}
        }
        
        
        function init() {
           // quit if this function has already been called
           if (arguments.callee.done) return;
           // flag this function so we don't do the same thing twice
           arguments.callee.done = true;
           // process menus
        	var mmenu = document.getElementById('mainMenu');
        	var mheads = mmenu.getElementsByTagName('li');
        	for (i = 0; i < mheads.length; i++) {
        		if (mheads[i].className == 'hasmenu'){
        			var smenu = mheads[i].getElementsByTagName('ul')[0];
        			smenu.style.display = 'none';
        		}
        	}
        }
        
        /* for Mozilla */
        if (document.addEventListener) {
           document.addEventListener("DOMContentLoaded", init, false);
        }
        
        /* for Internet Explorer */
        /*@cc_on @*/
        /*@if (@_win32)
           document.write("<script defer src=[(base_url)]assets/templates/ie_onload.js><"+"/script>");
        /*@end @*/
        
        /* for other browsers */
        window.onload = init;
        </script>


        This line: [tt]document.write("<script defer src=[(base_url)]assets/templates/ie_onload.js><"+"/script>");[/tt] calls an external file, ie_onload.js that just contains this: [tt]init();[/tt] Still, it doesn’t work...

        FINALLY, WAYFINDER SNIPPET CALL (using UltimateParent snippet to search for top container of documents):
        [tt][[Wayfinder? &startId=`[[UltimateParent]]` &level=`2` &outerTpl=`wfOuter` &rowTpl=`wfRow` &parentRowTpl=`wfParentRow` &innerTpl=`wfInner` &innerRowTpl=`wfInnerRow` &parentClass=`hasmenu` &hereClass=`active` &lastClass=`` &jsTpl=`wfJs`]][/tt]

        That’s it! I’d like to have further input from the js gurus out there with the issues I mentioned...

        Regards,
        JP
          Got Music? Try XSPFjukebox - Skinnable MODx Media Player
          • 36446
          • 184 Posts
          Hi!
          First of all: Thank you for your nice Accordion Menus and the tutorials. Whithout that i never would be able to get such a thing working!
          I tried all three accordion menus but decided to use the one from joeindio because it can handle a 3 level menu strukture and the content of the Container is opened when the Menu is opened up, but there is also a problem with this solution:
          In the wfParentRow Chunk the Link of the Containers to open the menu are set up with an <a href...> tag so that beside the menu, the content of the container is openened and showed in the [*content] of the page. This forces the site to load a new page and this leads to a crackling scrolling menu because the site is reloading while opening up the menu.
          I tried to replace the <a href....> tags from the wfParentRow Chunk by <h3... tags like in dozes menu - but then the containers which whrere no more active are not closing automatically so the menu gets longer and longer. Im a real noob with JS - maybe someone can help me to find a solution! A solution could be: using dozes menu if it could handle a 3 level site structure, or using joeindios menu if the reload function could be disabled....
          Thanx!
          Greez
          sven

            https://www.beautyislife-shop.de - premium make-up!
            https://www.topsterne.de - sell it here!
            ---------------------------------------------------------
            • 11526
            • 93 Posts
            Quote from: doze at Oct 12, 2006, 04:17 PM

            Look here.

            Just tryed this tutorial, and it works fine...

            ... until I log in on the manager and then preview my site... Then I get an "error on page" in my statusbar in IE.

            I think this menu isn’t compatible with QuickEdit, anybody alse also having this problem? I am using the last version of MODx (0.9.6).

            Thanks in advance!