We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14617
    • 47 Posts
    Hi all. This is my first post in the forums - but hopefully not the last wink

    I have a menu structure in 3 levels. I need to create a wayfinder call that says:
    "When in level 2, make a list of my children
    when in level 3 make list of my parents children (my siblings)"

    I can’t seem to find a way to do that. But I’m only a modx n00b
      • 7231
      • 4,205 Posts
      The parameter that makes the menu behave as you describe is &hideSubMenus. Set this to &hideSubMenus=`TRUE` and the sub menus will only show when the section is active.

      There is a whole lot of cool Wayfinder info at:
      http://www.muddydogpaws.com/development/wayfinder/parameters.html
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 8894
        • 114 Posts
        Sorry, I don’t understand what you want to do ...
        Could you explain more, maybe with an example document tree ?
          • 14617
          • 47 Posts
          Ex.

          Level 1 Page 1
          --- Level 2 Page 1
          --- --- Level 3 page 1
          --- --- Level 3 page 2
          --- --- Level 3 page 3
          ---Level 2 Page 2
          Level 1 Page 2
          Level 1 Page 3

          I need a Wayfinder call that does the following:
          When viewing a level 2 document, output a list of the level 3 documents.
          When viewing a level 3 document, output a list of the level 3 documents.

          The way I do it now is using 2 calls:
          [!Wayfinder? &startId=`[*id*]`&level=`1`!]
          [!Wayfinder? &startId=`[*parent*]`&level=`1`&excludeDocs=`22,23,24`!]
          excludeDocs being the level 1 id’s so I don’t get them when viewing a level 2 page.


          It works but it’s ’static’, meaning I have to update the template every time I add a new level 1 document sad

          Did that make it any clearer? huh


            • 8894
            • 114 Posts
            I think the simpliest way is to write a snippet which decides which value to put into &startId parameter.
            Your Wayfinder call will become:
            [tt][!Wayfinder? &startId=`[!theSnippetName!]`&level=`1`!][/tt]

            The snippet code could be:
            <?php
            switch (count($modx->getParentIds($modx->documentIdentifier))) {
            case 1: // we're in level 2
              return $modx->documentObject['id'];
            case 2: // we're in level 3
              return $modx->documentObject['parent'];
            default: // other levels
              return 0;
            }
            ?>
              • 14617
              • 47 Posts
              Hi Enidan

              Thank you for your answer.

              When I try what you suggest It outputs the following:
              &level=`1`]]

              I made the snippet and called it as you suggested. Did you try this on a system? Did it work?
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                You need to alternate the snippet call types; the inner snippet should be uncached [[...]] and the outer snippet cached [!...!].
                  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
                  • 14617
                  • 47 Posts
                  You’re a genius! Thank you very much. I needed to edit the snippet to

                  <?php
                  switch (count($modx->getParentIds($modx->documentIdentifier))) {
                  case 0: //we're in level 1
                   return $modx->documentObject['id'];
                  case 1: // we're in level 2
                    return $modx->documentObject['parent'];
                  case 2: // we're in level 3
                    return $modx->documentObject['parent'];
                  default: // other levels
                   return 0;
                  }
                  ?>


                  so it included level 1, but I couldn’t have done it without your help. Thank you very much!