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

    Been trying to figure this one out but can't. I am using Wayfinder in Evolution and I need to create what is basically a standard left hand navigation. Trouble is the way the tree structure is (and needs to be according to a previous dev) means I need to ignore 1 level of structure and display it on the front-end as if it wasn't there. So in the tree I have

    item 1
    -sublevel item 1
    -- sublevel item 1 child 1
    -- sublevel item 1 child 2
    item 2
    - sublevel item 2
    -- sublevel item 2 child 1
    -- sublevel item 2 child 2

    On the front-end, if I select item 1, I would like to see
    item 1
    - sublevel item 1 child 1
    - sublevel item 1 child 2
    item 2

    if I select item 2, I'd like to see
    item 1
    item 2
    - sublevel item 2 child 1
    - sublevel item 2 child 2

    This means I need to basically ignore the 'sublevel item X' items.
    I have tried hiding sublevel item from menu, but that means none of the children get picked up. I have tried exlcuding the items, same problem, no children.

    Anyone got in idea? the 'sublevel item X' have all got the same template which is different from anything else. AFAIK there is no 'ignore template' option in Wayfinder?

    Thanks for your help!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use a Template Variable for the startId value. The TV's default value should be @INHERIT. Now, for each sublevel parent (whose children you want in the menu), edit the TV and put in its own resource ID. Its children will inherit that value, so their Wayfinder calls will have that ID as their startId value.
        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
        • 37758
        • 73 Posts
        Hi,
        Thanks for the quick reply, but that doesn't work - it means I loose the other items of the same level. following the example, this would only give me

        - sublevel item 2 child 1
        - sublevel item 2 child 2

        But I need it to be if I select item 1
        item 1
        - sublevel item 1 child 1
        - sublevel item 1 child 2
        item 2

        Or am i missing something here?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah. Sorry, I misunderstood what you wanted. Have you tried the &hideSubMenus=`1` property? That will hide all submenus except for those belonging to the page you've selected.
            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
            • 22427
            • 793 Posts
            You could use the placeholder [[wf.level]] which gives the level of the actual item in the menu tree.

            Then use output modifiers to prevent the second level beeing displayed.

            The Wayfinder call:
            [[!Wayfinder? &startId=`0` &innerRowTpl=`innerRow`]]
            (or whatever your &startId is).

            The innerRow chunk:
            <li [[+wf.classes]]>[[+wf.level:is=`2`:then=``:else=`
            <a href="[[+wf.link]]" title="[[+wf.title]]" [[+wf.attributes]]>[[+wf.linktext]]</a>
            `]][[+wf.wrapper]]</li>

            The only issue I see: Obviously &hideSubMenus=`1` would not work as you would expect it to do.
              • 37758
              • 73 Posts
              hi @sottwell, yeah, sorry, have tried the &hideSubMenus=`1` property but it doesn't work as I need to show the submenu items of the submenu, thereby skipping 1 level

              @ottogal: thank you for the suggestion, I did think I may nee to do some snippet call to make this happen but even then wasn't sure how I would go about it. I will give your suggestion a whirl and get back here
                • 37758
                • 73 Posts
                @ottogal: thanks again, tried your suggestion but as I am using Evolution, the wf.level parameter is not available AFAIK http://muddydogpaws.com/development/wayfinder/parameters.html. Just if someone else thinks of trying it, though, you used the Revolution syntax (as I work with Revolution, too, I didn't notice that at first)

                Anyone else got any good ideas?
                  • 22427
                  • 793 Posts
                  Sorry, I overlooked you're using Evo.
                  To replace the non existent wf.level parameter you can use an own snippet which returns the level. I'm searching for an example and will tell you when I find it.

                    • 22427
                    • 793 Posts
                    Try to define a PHx modifier "getLevel":
                    <?php
                    return count($modx->getParentIds($input));
                    and use it in your &innerRow chunk like this:
                    [+wf.docid:getLevel+]
                    (where in Revo you would use [[+wf.level]])
                      • 37758
                      • 73 Posts
                      Thanks for that. A few things I have problems with, maybe you can help
                      firstly, I think it should say $output, not $input?

                      Using [+wf.docid:getLevel+] does give me 0, so I've changed it to
                      [+phx:input=`[+wf.docid+]`:getLevel+] which seems to give me the right levels.

                      One thing I don't understand is that it only works if I put this in the innerRow chunk

                      <li>[+wf.wrapper+]</li>
                      [+phx:input=`[+wf.docid+]`:getLevel:is=`2`:then=``:else=`<li><a title="[+wf.title+]" href="[+wf.link+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>`+]

                      If I just have
                      [+phx:input=`[+wf.docid+]`:getLevel:is=`2`:then=``:else=`<li><a title="[+wf.title+]" href="[+wf.link+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>`+]

                      I don't get anything back, I need to add <li>[+wf.wrapper+]</li>. Do you know why that would be? Confused