Setting placeholder in Evolution CMS
Sometimes there is just a need to set up your own placeholder!
Snippet
Our snippet is going to retrieve data from any TV of specified document. Snippet name "ph".
<?php
// Setting placeholder with any document TV on page
// Usage example: [ [ ph? &tv=`id` &id=`123` &ph=`my_placeholder_name` ] ]
// By: Piotr Matysiak / pm-fx.com
if($method=='get'){$id = $_GET['id'];}
$output = $modx->getTemplateVarOutput(array("$tv"),$docid="$id",$published=1);
$output = $output[''.$tv.''];
$modx->setPlaceholder($ph, $output );
return;
?>
Usage example
[ [ ph? &tv=`pagetitle` &id=`56` &ph=`myPh` ] ]
This will set placeholder named "myPh" which will contain page title of document with id 56. We can display it content by including [ + myPh + ]
Parameters
- tv - name of Template Variable we want to retrieve
- id - id of document with TV
- ph - our placeholder name