We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    two snippets:

    setPlaceholders:
    foreach($scriptProperties as $name => $value){
        $modx->setPlaceholder($name,$value);
    }
    


    getPlaceholder:
    return $modx->getPlaceholder($name);


    when I do this:

    [[setPlaceholders? &ph1=`test` &ph2=`test2`]]
    [[getPlaceholder? &name=`ph1`]]
    


    I get: test

    when I do this:

    [[getPlaceholder? &name=`ph1`]]
    [[setPlaceholders? &ph1=`test` &ph2=`test2`]]
    


    I get nothing

    when I do this:
    [[+ph1]]
    [[setPlaceholders? &ph1=`test` &ph2=`test2`]]


    I get 'test' again


    [ed. note: Bruno17 last edited this post 14 years ago.]
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 4172
      • 5,888 Posts
      you need to make sure to set all placeholders by one snippet, before you can get them in another snippet.

      Perhaps there are better ways at all, to get done, what your're after.
      Can you explain it a bit more?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Uncache your getter snippet, or put your setter snippet earlier in the document.

        If your getter snippet gets processed before the setter snippet, the value isn't yet in the "placeholders" array, so the snippet doesn't find it. A placeholder, however, will remain until after the last pass of the parser, when any unused placeholders will get removed. In the meantime, the setter snippet was processed, so in the next pass of the parser the placeholder will get replaced with the 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
          • 4172
          • 5,888 Posts
          Uncache your getter snippet, or put your setter snippet earlier in the document.

          which means this, to complete the list above:

          [[!getPlaceholder? &name=`ph1`]]
          [[setPlaceholders? &ph1=`test` &ph2=`test2`]]


          this is also working
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40553
            • 42 Posts
            Solved! I really appreciate your pacience. The whole snippet processing makes sense to me right now, even though the multiple page parsing seems to be the troublemaker in this case if one doesn't know about it. The workaround for using placeholders is a $_REQUEST once properly secured.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I think by default the parser makes up to 10 passes over the document; or stops when a checksum of the document hasn't changed. Then it does a bit of post-processing and sends the page off to the server. At any rate that's how the Evo parser works; I may be wrong here and Revo may work totally differently.
                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