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

    I use the following to display the list of resources in a container

    [[Wayfinder? &startId=`[[*parent]]` &level=`1` &outerTpl=`outerTpl` &rowTpl=`rowTpl` &innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`]]


    which works fine if the item I open is a child and not a parent.

    How do I achieve

    IF current id is a child
    DO x ....[[Wayfinder? &startId=`[[*parent]]` &level=`1` &outerTpl=`outerTpl` &rowTpl=`rowTpl` &innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`]]
    ELSE
    DO y ...[[Wayfinder? &startId=`[[*parent]]` &level=`1` &outerTpl=`outerTpl` &rowTpl=`rowTpl` &innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`]]


    Thanks
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Are your 2 examples there the same?

      I always recommend avoiding output filters whenever there's another way to do this -- output filters can become tangled messes and are difficult to debug and impossible to cache, so they are often a bad tradeoff for appearances.

      If I were you, I would write a custom snippet (which you'd be doing anyway if you were to write a custom output filter http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29#InputandOutputFilters%28OutputModifiers%29-CreatingaCustomOutputModifier)

      Just use runSnippet() to call one or the other variations of Wayfinder that you need (http://rtfm.modx.com/display/revolution20/modX.runSnippet), e.g.

      <?php
      // UNTESTED
      if ($modx->resource->get('isfolder')) {
          $args = array();
          // insert properties here
          return $modx->runSnippet('Wayfinder', $args);
      }
      else {
          $args = array();
          // insert other properties here
          return $modx->runSnippet('Wayfinder', $args);
      }
      


      Or, if you want to avoid the hassle of dealing with various behaviors, just peg your folders as folders and not as URLs -- you can do this by using the "getFirstChild" snippet, which redirects to the first child inside of a folder. I also saw a good trick the other day: create a webLink and set its target as the first child (for weblinks can also be treated as folders).

      Hope that helps.
        • 4172
        • 5,888 Posts
        the ultimateParent-snippet may help to solve your problem
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 12410
          • 353 Posts
          Hi,
          Thanks Guys. The below works for me but if you can recommend something better then great

           [[If?
             &subject=`[[*isfolder]]`
             &operator=`EQ`
             &operand=`1`
             &then=`<ul class="nav nav-list primary pull-bottom">[[!getResources? &parents=`[[*id]]` &tpl=`simpleLi`]]</ul>`
             &else=`[[Wayfinder? &startId=`[[*parent]]` &level=`1` &outerTpl=`outerTpl` &rowTpl=`rowTpl` &innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`]]`
             ]]


          From what I understand ultimateparent requires wayfinder to be uncached (performance impact?) and ultimateparent always returns the topmost container parent in the tree and not the parent of the current resource(child)... or maybe its me doing something wrong.

          Everett, how would I apply the above to your php code? Have u a link for the getFirstChild or is it this?
          http://modx.com/extras/package/firstchildredirect
          Thanks
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            If that works, then great. I don't like if-statements in the view layer because of the aforementioned difficulties in debugging: so just make sure it's clean and not a pain to debug. Any reason you're using Wayfinder for one and getResources for the other? And why is one cached and the other not?