We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Try making the comparison to greater than or isnot null. I’ve seen problems with trying to get it to work with empty before.
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 4172
      • 5,888 Posts
      Here I have a way which seems to work:
      snippet Dittoouter:
      <?php
      //[!Dittoouter? &output=`header`!]
      //[!Dittoouter? &output=`footer`!]
      $resource=$modx->getPlaceholder('ditto_resource');
      $out='';
      if (count($resource)>0){
      if ($output=='header'){
      $out='<p>Header</p>';
      }
      if ($output=='footer'){
      $out='<p>Footer</p>';
      }
      }
      return $out;
      ?>


      extender outerTpl.extender.inc.php:
      <?php
      
      $header = '[[Dittoouter? &output=`header`]]';
      $footer = '[[Dittoouter? &output=`footer`]]';
      $save = 2;
      
      ?>



      Dittocall:
      [!Ditto? .........................&extenders=`outerTpl`!]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 9849
        • 74 Posts
        Wonderful!

        This just works. If I one changes &output into &header and &footer in the "Dittoouter" snippet, one could pass the content of header and footer to the script and this way use it more general.

        Thank you very much Bruno17!
        • Maybe this PHx Modifier is useful, too.

          <?php
          // description: surround not empty string with text
          // usage: [+string:outer=`before|after`+]
          // example for an outerTpl for Ditto: [*phx:input=`[[Ditto? &noResults=` `]]`:outer=`<div class="xyz">|</div>`*]
          $options = explode("|", $options);
          $outer = '';
          if (trim($output) != '') $outer = $options[0].$output.$options[1];
          return $outer;
          ?>

            • 36805
            • 354 Posts
            Jako's your solutions seems to be very elegant as Ditto comes with PHx anyways. However I don't know how to install it properly. I know this thread is old but am still hoping for a hint.

            I don't know where to save the phx and how to name it. Also the bracket-star notation [*phx .. *] seems unusual. Is this correct?

            My goal seems simple enough. Below you can see my ditto config for which I'd need my second level list in an <ul></ul> if nonempty. The second level config looks similar but without any further Ditto call.

            <?php
            
            $tpl = '@CODE:
            <li class="level1">
                <a href="[~[+id+]~]">[+pagetitle+]</a>
                <ul>
                    [!Ditto? &startID=`[+id+]` &config=`subnavlevel2`!]
                </ul>
            </li>
            ';
            
            $tplLast = '@CODE:
            <li class="level1 last">
                <a href="[~[+id+]~]">[+pagetitle+]</a>
                <ul>
                    [!Ditto? &startID=`[+id+]` &config=`subnavlevel2`!]
                </ul>
            </li>
            ';
            
            $noResults = ' ';
            $where = 'template = 5';
            $sortBy = 'menuindex ASC';
            
            ?>