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 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?
-
☆ 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.
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
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.
-
☆ 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.