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

    I’m revamping my website at the moment and tought it was time to get rid of Dropmenu and adopt WayFinder instead...

    The navigation will be done using tabs as you can see in the attached screenshot. ’Les prix’ is the current tab and ’Les stations, Les services, ...’ the other main categories. The ellipse indicates the sub-categories of ’Les prix’.

    The document tree looks like this:

    some nav container ( 250)
    - Les Prix ( 50)
    - Bruxelles-Capitale ( 80)
    - Brabant-Wallon ( 90)
    - ...
    - Les stations ( 60)
    - Les services ( 70)
    - ...

    I managed to elaborate the WayFinder ’swear’ to have the current tab stand out ( in this case I’m in document 50) as you can see:

    [tt][!Wayfinder? &startId=`250` &level=`1` &outerTpl=`wfOuter` &rowTpl=`wfRow` &hereTpl=`wfHere` &activeParentRowTpl=`wfHere`!]
    [/tt]
    however, when I navigate to a subcategory the parent categorie remains like the others...

    I’ve been thru a lot of documentation already but can’t seem to get it right... any pointers?

    TIA
      A thing of beauty is a joy forever ( John Keats)
      • 2472
      • 151 Posts
      The good news is that I finally got it working ( after a few evenings), the bad is that Wayfinder is not the most intuitive snippet around... imho. In fact I now know how it got it’s name... considering the time I needed to, ahum ’find my way’. grin

      The get a grip on how Wayfinder ticks I went thru lots of documentation and experimenting. Resigning to the good old ’trial and error’ method in fine. Here’s how I did it:

      - First code yourself a pure HTML example of what you want, right in your template and where you want it. Typically it goes something like this:
      <h3>Nice title</h3>
      <ul>
      <li>first</li>
      <li>second</li>
      </ul>
      

      Check that your html code is valid and everything displays and feels ok. Do this before you even try convincing wf to generate code for you. wink

      - After reading up on the wiki to know what exactly wf does I made myself a ’debugging’ Wayfinder call that I inserted in my template, right after my example html code:
      [!Wayfinder? &startId=`48` &level= `2` &outerTpl=`wf.outer` &rowTpl=`wf.row` &parentRowTpl=`wf.parentRow` &parentRowHereTpl=`wf.parentRowHere` &innerTpl=`wf.inner` &hereTpl=`wf.here` &innerRowTpl=`wf.innerRow` &innerHereTpl=`wf.innerHere` &activeParentRowTpl=`wf.activeParentRow` &categoryFoldersTpl=`wf.categoryFolders` !]
      

      Don’t forget to change startId and level to your context!

      - The chunks look like these, code comes straight from the wiki. For instance the wf.Outer chunk:
      <!-- Wayfinder debugging starts here:
      <ul wf="Outer" id="topnav"[+wf.classes+]>[+wf.wrapper+]</ul>
      -->

      I made it start with an html comment, so the generated code will not mix up your screen while your developping the wf call.

      - The wf.parentRow chunk:
      <li wf="parentRow" [+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>

      You’ll notice I did add a bogus attribute wf so I can trace which template got processed. cool

      - The general idea is now to display your page in a browser and to take a look at it’s source code ( right click the page, View source) in order to compare the example code with the code that Wayfinder produced.

      - Look for templates you can use to math the example code.

      - Make a copy of the ’debugging’ Wayfinder call before you start, the original will help you out while you’re develloping the definitive one. Replace one template at a time and take a close look on the Wayfinder behaviour while you test different pages.

      - Sometimes you’ll want Wayfinder to generate nothing at all, in that case I use a wf.span chunk:
      <!-- [+wf.docid+] -->

      If you don’t provide a template wf will generate some context based standard code... use this if it doesn’t fit your purpose.

      - If you don’t wan’t any code generated but would like Wayfinder to drill down the document structure, use a wf.wrap chunk:
      [+wf.wrapper+]


      - Once the Wayfinder code is equal to the example code you’re done. Comment out the example code and the ’debugging’ call.

      That’s about it, I hope this will help you master Wayfinder faster than I did. ;-).
        A thing of beauty is a joy forever ( John Keats)
        • 30030
        • 22 Posts
        Your site looks nice and glad you figured out your problem. I’m only posting because I’m new to MODx and too many times I read a thread where someone asks an interesting question only to reply "Figured it out!" and nothing else... so nice to see someone take the time and post the answer for others so thanks! smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Actually that’s about the way I do it too. Make a static menu like I want, then work out the templates and parameters WF needs to reproduce it. The "config" parameter and external configuration files are really great!
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 15001
            • 697 Posts
            I’m just trying to do tabbed navigation with Wayfinder.

            How do build the tab structure is explained here: http://wiki.modxcms.com/index.php/Tabbed_content

            I split the given code into several files :
            - tabs.js with all the Javascript code
            - tabs.css for the styling
            - tabs.config.php with the code describing the Wayfinder chunks to create the tabs :
            <?php
            $startId=49;
            $level=1;
            $outerClass = 'tabs';
            $outerTpl = '@CODE:<div id="nav">
            <ul>
            [+wf.wrapper+]
            </ul>
            </div>';
            $rowTpl = '@CODE:<li>[+wf.title+]</li>';
            $cssTpl = '@CODE:<link rel="stylesheet" media="all" type="text/css" href="assets/snippets/wayfinder/css/tabs.css" />';
            $jsTpl = '@CODE:<script type="text/javascript" src="assets/snippets/wayfinder/scripts/tabs.js" />';
            ?>

            Now, I wonder how to put the content of the child documents into the tabs ?
            Should I use a second call of Wayfinder and the rows making Ditto calls ?
            Is there some Wayfinder’s placeholder that directly retrieves the main content of child documents ?

            The structure to create is :
              <div id="data">
                <div id="one">
                  Page one
                </div>
                <div id="two">
                  Page two
                </div>
                <div id="three">
                  Page three
                </div>
              </div>

            So, the question is how to create this dynamically with the content of the docs instead of "Page one", "Page two", a.s.o.

            <!-- Building the tab structure -->
            <div id="tabs">
            [!Wayfinder? &config=`tabs` !]
            [!Wayfinder? &config=`tabcontents`  !]
            </div>


            Thanks for any help.