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

    I’m trying to run a ditto call, but instead of rendering HTML to the screen, I’d like for it to just return a list of the IDS that it has found that match all of my criteria. I’m doing some interesting filtering, and in the end the result of a first ditto call will become the "&documents" parameter for a second ditto call which will do some additional filtering.

    Is there a way to have ditto just send me back the ID’s of the result-set?

    Thanks Everyone!
    CodeDOC

      • 10449
      • 956 Posts
      You could run Ditto via snippet, e.g.

      <?php
      $documents = $modx->runSnippet("Ditto", array(
      	"parents" => 50,
      	"display" => "all",
      	"depth" => 0,
      	"showPublishedOnly" => 1,
      	"seeThruUnpub" => 0,
      	"showInMenuOnly" => 1,
      	"tpl" => "@CODE [+id+]," )
      );
      $docs = substr($documents, 0, strlen($documents)-1); // remove last comma from string
      $d = explode( ',', $docs);
      return($d);
      ?>
      


      See also this (somewhat related) discussion here: http://modxcms.com/forums/index.php/topic,22997
        • 5586
        • 8 Posts
        Brilliant! Thanks so much.