We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38800
    • 35 Posts
    I have a website with several "top level" pages, most of which have several child pages.

    When a user browses one of the top level pages, I want Wayfinder to display links to that page's children in a side menu entitled "In this section". The following works fine for this:

    [[!Wayfinder? & level=`1` & outerClass=`submenu` & scheme=`full`]]


    However! If the user browses to one of the child pages, the "In this section" menu becomes blank, which makes sense because the currently active page now doesn't have any children for Wayfinder to display. How can I persuade Wayfinder to display links to the child page's sibling pages? (and still have it work when browsing the parent)

      • 42562
      • 1,145 Posts
      I suppose you mean you are using the same site template for both Parent and Children pages? Then some logic might work.
      I will assume Parent Ids are : 4, 8, 9, 11, 34, 345 ..
      <div id="sidebar">
      [[*id:is=`4`:or:is=`8`:or:is=`9`:or:is=`11`:then=`[[$Inthissection]]`:else=``]]
      //even better, use the bellow:
      [[[[*id:is=`4`:or:is=`8`:or:is=`9`:or:is=`11`:then=`$Inthissection`:else=``]]]]
      
      
      [[Wayfinder? &startId=`[[*id]]` &level=`1` &outerClass=`submenu` &scheme=`full`]]
      </div>


      If Page 4, or 8 or 9 is being viewed, this chunk will show, [[$Inthissection]], which is your heading with CSS attached.
      4, 8 and 9 being parents, Wayfinder will have some children to show, because the [[*id]] in the Wayfinder call will change to 4, or 8 or 9, and Wayfinder will start processing from that Id.

      If Page 200 (a non-parent, but a child of 8 ) is being viewed, the [[*id]] will change to 200 but Wayfinder will have no children and nothing to show. So your <div id="sidebar"></div> will be nice and blank.

      You could of course write a snippet to take care of this and also prevent Wayfinder from being called at all when not needed.

      Hope this is a start to your answer..
      Cheers
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        For this, I use a TV with @INHERIT binding, and in the parent resources set it to the parent resource's ID. Then I use that TV for the startId value. The children will inherit the parent's value for their TVs.
          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
          • 38800
          • 35 Posts
          Thanks Don and Susan for getting back to me so quickly on this.

          I ended up using the TV / @INHERIT binding option. Works perfectly!

          Regards,
          Dave
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I think that was my very first use of TVs back in the days of Etomite + MODX2 extensions wink
              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
              • 34152
              • 1 Posts
              That is incredibly useful! Would there be a way of automatically filling in the TV with the parent ID rather than hoping my client will remember to fill it in? Thanks!