We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28121
    • 107 Posts
    I’m about to build my first commercial site using ModX for a client and I’m trying to get some insight into how I’d construct each ’sections’ side navigation using Wayfinder snippet without having to resort to a seperate template for each section.

    I have several ’channels’ running along the top navigation

    Home | Company | Services | News | Resources

    Company will have a side navigation as follows..

    Company
    - About Us
    - Our Team
    - - Person A
    - - Person B
    - - Person C
    - Awards
    - Contact
    - - Office US
    - - Office UK
    - - Office UAE

    Ideally, when you land on Company, you should see the side navigation list of pages (About, Team, Awards, Contact) but you should ONLY see the Team sub pages when you are actually on the Team page.

    Initially I was thinking that although every page here is built on the exact same template, that I could use multiple versions of the same template with a slightly different WayFinder snippet in each.

    Or am I in fact better off manking the side navigation a Template Variable to which I can assign a seperate WayFinder Snippet or even call a chunk which holds a Snippet?

    Feeling confused :O)
    Thanks in advance for any replies.



      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use the same template. Wayfinder is designed to handle this very common situation.

      You can use Wayfinder in the side menu with its &hideSubMenus=`1` option; this will prevent the display of the second-level (well, actually third-level) menu items until you are on the parent (in this case the second-level) page.

      Use the UltimateParent snippet as the startId value.
      [!Wayfinder? &startId=`[[UltimateParent]]` ... !]

      The Wayfinder has to be uncached, and the UltimateParent cached to get the snippet nesting to work properly; the UltimateParent snippet will be processed first, so that when the Wayfinder snippet is later processed the correct value will be available to it.

      So if you are on the Company page, the side menu will use that resource ID for its starting point. The side menu will show only the second-level items under Company. Go to the Our Team page, and the same menu will show, except that now its submenu of Person A, Person B etc will be generated.
        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
        • 28121
        • 107 Posts
        Hi Susan
        Thanks for the instructions. Am trying it out at the moment and I have the beginnings of it working for me on the folliwng ’FULL TREE’

        * Root
        * Level 1
        * Level 2
        * Level 3
        o Level 3.1
        o Level 3.2
        o Level 3.3
        * Level 4
        o Level 4.1
        o Level 4.2
        o Level 4.3
        * Level 5

        When I click on the Level 1 link I have the tree showing with only 1 level of children (1,2,3,4,5) showing.
        My Wayfinder code is as follows
        [!Wayfinder? &startId=`[[UltimateParent]]`&level=`1` !]

        When I click on Level 3 link, I have the the tree showing the following as desired (1,2,3,3.1,3.2,3.3,4,4.1,4.2,4.4,5)
        My wayfinder here is
        [!Wayfinder? &startId=`[[UltimateParent]]`&level=`2` !]

        Almost there with the exception that it’s showing the 4 and 4.1,4.2,4.3 links when I am only browsing level 3.

        huh


          • 28121
          • 107 Posts
          Have been meaning to share the solution for this which I eventually cobbled from other people’s posts and suggestions.

          [!Wayfinder? &startId=`[[UltimateParent]]` &displayStart=`1` &rowClass=`sidenav` &hideSubMenus=`1` !]