We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18628
    • 16 Posts
    I’ve gone through the accordion menu example in the Wayfinder wiki and it seems to mostly work, except that when the page first loads the first link doesn’t work. You can click on it all you like and it just won’t expand that section. If you click on the link below, it’s section of the menu expands as it should. Has anyone come across this before?

    This is the code generated by Wayfinder, which looks ok to me:

    <div id="accordion"><div id="panel7">
    	<h3 onClick="accordion(this)">SEARCH</h3>
    	<div id="panel7-body" class="panel_body">
    		<div>
    			<ul>
    				<li><a href="http://www.yahoo.co.uk" title="Yahoo" >YAHOO</a></li>
    				<li><a href="http://uk.ask.com/" title="Ask Jeeves" >ASK JEEVES</a></li>
    				<li class="last"><a href="http://www.google.co.uk" title="Google" >GOOGLE</a></li>
    			</ul>
    		</div>
    	</div>
    </div>
    <div id="panel11">
    	<h3 onClick="accordion(this)">ACCOUNTANCY</h3>
    	<div id="panel11-body" class="panel_body">
    		<div>
    			<ul>
    				<li><a href="http://uk.lockton.com/Professions/" title="Alexander Forbes" >ALEXANDER FORBES</a></li>
    				<li><a href="http://www.accaglobal.com/" title="ACCA" >ACCA</a></li>
    				<li><a href="http://www.accountancyage.com/" title="Accountancy Age" >ACCOUNTANCY AGE</a></li>
    				<li><a href="http://www.bentley-jennison.co.uk/" title="Bentley Jennison" >BENTLEY JENNISON</a></li>
    				<li class="last"><a href="http://www.sayervincent.co.uk" title="Sayer Vincent" >SAYER VINCENT</a></li>
    			</ul>
    		</div>
    	</div>
    </div>
    
      • 7923
      • 4,213 Posts
      You don’t have the id="visible" there to make it open some block..

      if you have page structure like this:

      container 1
      |
      |- document 1
      |- document 2
      |- document 3
      container 2
      |- document 4
      |- document 5
      |- document 6

      You would set that document 1 for example in to Site Start in modx configuration, and not the containers. Have you setuped it like that?


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 18628
        • 16 Posts
        Hi doze. My menu structure is like this:

        Container (invisible - this is so I can have more than one menu on the page. I simply call the start id of this page in my wayfinder call)
        |- Container (visible)
        |- Link
        |- Link
        |- Link
        |- Container (visible)
        |- Link
        |- Link
        |- Link

        And so on...

        I followed the example in the wiki word-for-word (http://wiki.modxcms.com/index.php/Accordion_menu_with_Wayfinder). It didn’t mention anything about ’id="visible"’ anywhere. As I said, the first section won’t open, but the second will and there is no difference in the HTML that I can see.

        You can see how the menu should work on this external site (http://openrico.org/rico/demos.page?demo=rico_accordion). Here the first section is open by default - open or closed would fine fine for me either way.
          • 7923
          • 4,213 Posts
          Yes.. I know how it should work, or at least I think I know as I did that Wayfinder example..

          The menu that I did works so that it expands the block that has that id="visible" on it. The wayfinder parentRowHereTpl and activeParentRowTpl chunks are configured to set that id. So, if you go in your example tree to the first visible container or any of it’s childs, that block will be set to open.

          But, if you are not on any of the document’s that the menu lists, it doesn’t know which one to open.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 18628
            • 16 Posts
            First of all I’d like to thank you for doing the example on the wiki - I was pulling my hair out trying to figure out how to use wayfinder. The long list of parameters is great, but didn’t really give me an idea how to implement the menu. Your example was perfect!

            Ok, so onto my problem. I think I understand what you’re saying. Because I have the invisible container page it doesn’t know what page I’m on because it’s hidden. I assume I need to change the chunks to get round this. Is that right?
              • 7923
              • 4,213 Posts
              You should change the javascript that if that id="visible" is not found, it would open the first block anyways... or hide all. There is also some other variation of it here.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 21800
                • 174 Posts
                the accordion menu works fine so far but one thing disturbes:
                after loading the page, the menu first opens completely (like a pure wayfinder menu), then collapses to the correct size and appearence.

                what can be done so that the menu just appears in correct size from beginning?
                  • 7923
                  • 4,213 Posts
                  It happens because the HTML gets loaded and rendered before the javascript runs (what then shows the menu in accordion style). This example used prototype and scriptaculous javascript libraries which are not very compact ones and takes some time to load.

                  Few things come to mind that you could try:

                  1. You could modify your CSS so that the menu is hidden by default and then make it visible in the javascript. That way your menu will be visible only after the javascript has been loaded. Eg. add visibility: hidden to the #accordion {} block in the CSS and then document.getElementById(’accordion’).style.visibility="visible" to the wfJs chunk afther the addEvent(window, "load", init); line.

                  2. Use MooTools instead of prototype / scriptaculous


                    "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                    • 21800
                    • 174 Posts
                    thanx doze for friendly explanation
                    - 1. did not work for me
                    ("no element" error in that line document.getElementById(’accordion’).style.visibility="visible" after the addEvent(window, "load", init); line
                    - 2. I thought about that several times for scriptaculous is heavy load for most cases. But I usually need Gallery, Ajax Search and some show/hide things ... and I don’t really have no idea what else depends on that scripts (Ditto, eForm ...?).
                      • 7923
                      • 4,213 Posts
                      Newest MaxiGallery and Ajax Search versions use MooTools. Ditto and eForm doesn’t use scriptaculous/prototype by default I think.. But the first option should work too, I probably made some error in my example, you could try to debug it in firebug (firefox extension) and see what line throws that error.


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."