We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10289
    • 14 Posts
    Hi guys,

    Im building a site for a client and have foolishly promised him a main nav that runs along the top of the editable content (no problems) and a subnav that runs down the left hand side of individual pages (previously no problems). The issue arises because when he creates a new document with a subnav he needs to edit the "startId" parameter and create a new template to get the subnav working. Which is a bit techie for him.

    If I remove the startId parameter the top level, i.e. the parent document displays the subnav properly, however the child docs do not render the nav.

    Is there anyway to get the wayfinder snippet to detect the top level document automatically without directing it with the startId param?

    These are my wayfinder calls as they stand:

    top level:
    [!Wayfinder? &startId=`0` &level=`1` &hereClass=`selected`!]

    sub level:
    [!Wayfinder? &hereClass=`selected` &level=`2`!]

    Hope someone can help!
      • 25483
      • 741 Posts
      Try to use the UltimateParent snippet (don’t remember if it is included in MODx by default, but you could download it from the repository)

      [!Wayfinder? &startId=`[[UltimateParent]]` &level=`4` !]


      I did set a level 4 to allow childs to list their subnav too!
      UltimateParent will find the top level parent, not the direct parent.
        with regards,

        Ronald Lokers
        'Front-end developer' @ h2o Media

        • 10289
        • 14 Posts
        Perfect MediaGuy, I had to do a little fernagling to get it working properly, but its spot on now! You saved me hours of faffing with the nav. So thats a few more hours I get to faff with the search sad

        Thanks again.
          • 2148
          • 4 Posts
          How can set Wayfinder navigation to fit this code:

          <body
          	<div id="top">
              	<div id="lang">
                  	<ul>
                  	<li><a href="#">Home</a></li>
                      <li><a href="#">Language1</a></li>
          			<li><a href="#">Language2</a></li>
          			<li><a href="#">Language3</a></li>
                  	</ul>
                  </div>
              	
                  <div id="mainmenu">
                  	<ul>
                  	<li id="item1"><a href="#">Mainmenu1</a></li>
                      <li id="item2"><a href="#">Mainmenu2</a></li>
                      <li id="item3"><a href="#">Mainmenu3</a></li>
          			<li id="item4"><a href="#">Mainmenu4</a></li>
                      <li id="item5"><a href="#">Mainmenu5</a></li>
          			<li id="item6"><a href="#">Mainmenu6</a></li>
                  	</ul><
                  /div>
              </div>
              
              <div id="mid">
            		<div id="submenu">
                  	<ul>
                  	<li><a href="#">Submenu1</a></li>
                      <li><a href="#">Submenu2</a></li>
                      <li><a href="#">Submenu3</a></li>
          			<li><a href="#">Submenu4</a></li>
                      <li><a href="#">Submenu5</a></li>
          			<li><a href="#">Submenu6</a></li>
                      <li><a href="#">Submenu7</a></li>
                 		</ul>
                  </div>
              </div>
          </body>


          What I did is:

          <body
          	<div id="top">
              	<div id="lang">
                  	[!Wayfinder? &startId=`0` &level=`1`!]
                  </div>
              	
                  <div id="mainmenu">
                  	[!Wayfinder? &startId=`[[UltimateParent]]` &level=`1`!]
                  </div>
              </div>
              
              <div id="mid">
            		<div id="submenu">
                  	[!Wayfinder? &startId=`[*id*]` &level=`1`!]
                  </div>
              </div>
          </body>


          The logic is simple. We have language selection. And within each language different main menus (like separate websites). When we click main menu link - we may not or may have different submenu for different main menu link. The code above seems to work up untill I click the submenu link - then all submenu links simply disappear. It seems logical as it, after clicking it, tries to put into code the child links of submenu which do not exist. But how can I make these submenu stay in the code and do not dissapear? Or maybe there is a more simple method for navigational system like this? I’m still have difficulties understanding how wayfinder works. Thank you in advance!
            • 2148
            • 4 Posts
            Through try and error managed to solve my problem. So if you use navigation system like I do, you don’t need to change anything within Wayfinder snippet (well you can set hideSubMenus to TRUE). Just the code:

            <body
            	<div id="top">
                	<div id="lang">
                    	[!Wayfinder? &startId=`0` &level=`1`!]
                    </div>
                	
                    <div id="mainmenu">
                    	[!Wayfinder? &startId=`[[UltimateParent]]` &level=`1`!]
                    </div>
                </div>
                
                <div id="mid">
              		<div id="submenu">
                    	[!Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]`!]
                    </div>
                </div>
            </body>