We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18646
    • 106 Posts
    I just discovered that you can use a dyanmic tokens like [*id*] and [*parent*] to process documents in the wayfinder, which is awesome. Much better then the method I was previously using. But I ran into a snag:

    using this code:
    [[Wayfinder? &startId=`[*parent*]` &level=`3`]]

    I’m displaying a menu like this:

    One
    Two
    Sub 1
    Sub 2
    Supersub 1
    Three


    The problem occurs when I select Supersub 1. The menu refreshes and it only shows:

    Sub 2
    Supersub 1


    This is not unexpected, because this is what I’ve asked the wayfinder to do. But what I need it to do is process everything from the parent document of One. The first menu I pasted as an example is the one I’m tyring to display. Is there a way to do this by using tokens? Is there some kind of a super parent token placeholder I could use?

    Thanks all.

    Regards,
    Matt
      • 10449
      • 956 Posts
        • 18646
        • 106 Posts
        I don’t think this will work in my situation, here’s why:

        Here’s my subnav again,
        One
        Two
        Sub 1
        Sub 2
        Supersub 1
        Three


        One is not the site root. It’s a root level page, but I only want this sub nav to show on the this page I’m on. So let’s say I’m on the About Us page. Using the Ultimate parent, I would have to define the top as a hard coded value (start processing at One). I want to use the same snippet of code to display the appropriate sub navigation on all root level pages. The supersub is where the problem begins. It starts processing at Sub 2.

        I found this old thread and this guy was trying to solve the exact same issue:
        http://modxcms.com/forums/index.php?action=printpage;topic=9320.0

        I’m trying to get the parent of a parent. It doesn’t seem like there is an easy way to do that.

        Regards,
        Matt
          • 3749
          • 24,544 Posts
          I’m totally making this up, but I think you could create a snippet called GetGrandparent with something like this:

          $id = $modx->documentIdentifier;
          
          return ($modx->getParent(getParent($id,1,'id'), 1, 'id'));


          That should return the grandparent’s id.

          Then put the a call to the GetGrandparent snippet inside the Wayfinder call instead of UltimateParent.

          [Update] Looking at the code of the UltimateParent snippet, I see that it takes a &top parameter which might help you:

          // [[UltimateParent? &id=`45` &top=`6`]]
          // will find the first parent of document #45 under document #6
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 18646
            • 106 Posts
            I think I’m actually getting closer to getting this working without writing new snippets.

            If I create a chunk called grandpa, define it’s contents as [[UlitmateParent]], and call it anywhere in the doc, I get the doc ID I’m looking for. So that’s perfect.

            But if I try to call the chunk within the wayfinder like this:
            [[Wayfinder? &startId=`{{grandpa}}` &level=`3`]]

            I would expect the value of grandpa to populate &startId, but it doesn’t. Am I calling this wrong? Can’t you call a chunk within a snippet?

            Regards,
            Matt


              • 3749
              • 24,544 Posts
              Quote from: matt6805 at Feb 02, 2009, 09:35 PM

              I think I’m actually getting closer to getting this working without writing new snippets.

              If I create a chunk called grandpa, define it’s contents as [[UlitmateParent]], and call it anywhere in the doc, I get the doc ID I’m looking for. So that’s perfect.

              But if I try to call the chunk within the wayfinder like this:
              [[Wayfinder? &startId=`{{grandpa}}` &level=`3`]]

              I would expect the value of grandpa to populate &startId, but it doesn’t. Am I calling this wrong? Can’t you call a chunk within a snippet?

              Regards,
              Matt

              You’re at the limits of my knowledge of the parsing order. Try putting an uncached call -- [!UltimateParent!] in the chunk (BTW, you misspelled UltimateParent in your post -- make sure it’s correct in the code).

              If that doesn’t work, the chunk reference is probably parsed too late to work for you.

              You could try calling a snippet in the Wayfinder call that just contains:

              <?php
              return $modx->getChunk('grandpa');
              ?>


              Try it cached and uncached.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 18646
                • 106 Posts
                Got it! I stumbled across a post where this call was made:

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

                I don’t really understand it myself, but this does exactly what I’ve been trying to accomplish. No extra configuration needed. I appreciate your help on this Bob! Until the next roadblock, I’m signing off smiley

                Regards,
                Matt
                  • 3749
                  • 24,544 Posts
                  Glad you got it sorted. smiley
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting