Is it possible to create some kind of global placeholders?
I tried doing something like this without success:
In an archive of articles I want to place previous/next links at the end of each article. So I called getResources twice:
[[!getResources?
&parents=`[[*parent]]`
&depth=`1`
&sortby=`menuindex`
&sortdir=`DESC`
&limit=`1`
&where=`{"menuindex:<":[[*menuindex]]}`
&tpl=`PrevLink`
]]
[[!getResources?
&parents=`[[*parent]]`
&depth=`1`
&sortby=`menuindex`
&sortdir=`ASC`
&limit=`1`
&where=`{"menuindex:>":[[*menuindex]]}`
&tpl=`NextLink`
]]
Now there should be a separator between the links, but only if needed. So in the PrevLink template I placed a snippet call
[[!SetPlaceholder?
&name=`prevLinkExists`
&value=`1`
]]
The snippet looks like this:
<?php
$name = $modx->getOption('name', $scriptProperties);
$value = $modx->getOption('value', $scriptProperties);
$modx->setPlaceholder($name, $value);
return;
and either in the NextLink template or before the second getResources call I tried
[[!+prevLinkExists:notempty=`<span class="linkSeparator">|</span>`]]
Well, this doesn’t work, and using a GetPlaceholder snippet doesn’t help, either.
I could use a third getResources call, but that would be overkill. I could also write a snippet that creates both links and the separator, but if it’s possible to solve this in a way similar to the one I tried, I’d like to know about it.
Thanks in advance for any suggestions!
Cheers,
Jan