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

    How does the parameter "save" work ... How can I access the placeholders?

    Regards,
    sucram
      • 11975
      • 2,542 Posts
      Hi,

      for a complete example of how to, have a look at the reflect source code.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 28796
        • 23 Posts
        Nice smiley

        The doc says "Saves the ditto object and results set to placeholders for use by other snippets"
        How do I access the placeholder?
          • 11975
          • 2,542 Posts
          From the ditto code


          if($save) {
          $modx->setPlaceholder($dittoID."ditto_object", $ditto);
          $modx->setPlaceholder($dittoID."ditto_resource", ($save == "1") ? array_slice($resource,$display) : $resource);

          So to get the $resource array or the ditto object


          $modx->getPlaceholder($dittoID."ditto_object", $ditto);
          $modx->getPlaceholder($dittoID."ditto_resource");

          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 29635
            • 361 Posts
            Sorry to be dense here, but from the looks of the code it looks like it should be replacing [+mydittoid_ditto_object+], yes?

            [!Ditto? &id=`home_events` &parents=`39` &tpl=`eventTradeshowHomepage` &display=`1` &save=`3`!]
            
            [+home_events_ditto_object+]
            [+home_events_ditto_resource+]
            


            That doesn’t output anything, however. I’m probably missing something obvious, but I could use some help if anybody’s got a moment. Thx.

            (Page is uncached. PHx is installed (problem, maybe?). Using Ditto 2.0.2.
              Need MODx Ecommerce? Try FoxyCart!
              • 23491 ☆ A M B ☆
              • 1,056 Posts
              Quote from: The at Jan 30, 2008, 05:06 PM

              Sorry to be dense here, but from the looks of the code it looks like it should be replacing [+mydittoid_ditto_object+], yes?

              [!Ditto? &id=`home_events` &parents=`39` &tpl=`eventTradeshowHomepage` &display=`1` &save=`3`!]
              
              [+home_events_ditto_object+]
              [+home_events_ditto_resource+]
              


              That doesn’t output anything, however. I’m probably missing something obvious, but I could use some help if anybody’s got a moment. Thx.

              (Page is uncached. PHx is installed (problem, maybe?). Using Ditto 2.0.2.

              PHx will parse out your placeholders before Ditto gets a chance to create them. You can call Ditto cached, page uncached and it might correct this behavior. Else, you’d have to store your placeholders in a chunk, then write a snippet to retrieve that chunk:


              [!getChunk? &chunk=`chunkNameHere`!]

              //<?php
              // getChunk snippet
              $chunk = isset( $chunk ) ? $chunk : null;
              return ( !$chunk ) ? '' : $modx->getChunk( $chunk );
              


              I’ve used this technique in the past when PHx is conflicting with placeholders.

              EDIT: In regards to placeholders [+ditto_resource+] and [+ditto_object+], a more detailed explanation can be found below smiley
                Mike Reid - www.pixelchutes.com
                MODx Ambassador / Contributor
                [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                ________________________________
                Where every pixel matters.
                • 18397
                • 3,250 Posts
                [+ditto_object+] contains a PHP object and [+ditto_resource+] contains a PHP array and thus will not reliably output text. They are designed to be retrieved with $modx->getPlaceholder like in Reflect. If you want to visually see their content you would need to create a snippet run after Ditto like so:
                <?php
                $dittoID='myID';
                $resource = $modx->getPlaceholder($dittoID."ditto_resource");
                return var_export($resource,true);
                ?>