Always set global placeholders before anything else in your template and you’ll never go wrong.
I believe that’s exactly what I’m doing, and I’m still going wrong.
Try this experiment:
snippet ’setPlaceholders’:
<?php
$modx->setPlaceholder('site', 2); // and 2 is a valid resource with alias 'test'
?>
chunk ’html’:
<!-- placeholder: [[+site]] || placeholder as link: [[~[[+site]]]] -->
Now create a resource that looks like this:
[[setPlaceholders]]
[[$html]]
You will get this output (well,
I do anyway):
<!-- placeholder: 2 || placeholder as link: -->
And an error is generated:
(ERROR) `[[+site]]` is not a valid integer and may not be passed to makeUrl()
Now change the setPlaceholders snippet to look like this:
<?php
$modx->setPlaceholder('site', 2);
return $modx->getChunk('html');
?>
And now the output is as you’d expect:
<!-- placeholder: 2 || placeholder as link: test.html -->