Hello, guys,
I'm making a snippet that uses ajax processor to pull the result.
I also use it to parse the template.
As following the @splittingred codes, I use this method inside the class to parse the template:
/**
* Initiating the templates.
* @param string $placehoders placeholders
* @return string templated result;
*/
public function getChunk($placehoders) {
$getChunk = $this->modx->getChunk($this->params['tpl']);
if (!empty($getChunk)) {
$output .= $this->modx->getChunk($this->params['tpl'], $placehoders);
} else {
$output .= $this->_getChunk('tpl', $this->params['tplFilePath'], $placehoders);
}
return $output;
}
private function _getChunk($name, $filePath, $params) {
$chunk = false;
if (!file_exists($filePath)) {
throw new Exception('Missing template file: ' . $filePath);
} else {
$o = file_get_contents($filePath);
$chunk = $this->modx->newObject('modChunk');
$chunk->set('name', $name);
$chunk->setContent($o);
return $chunk->process($params);
}
return FALSE;
}
It works nice on usual snippet's return, as I have this template in chunk (shortened version):
<div class="gcal-list [[+feedClass]]">
<b><a href="[[~14? &cid=`[[+calendarId]]` &eid=`[[+id]]`]]" title="Detail">[[+summary]]</a></b>
<div class="feedContent main-content">
[[+kind:notempty=`
<p>Kind: [[+kind]]</p>
`:default=``]]
[[+status:notempty=`
<p>Status: [[+status]]</p>
`:default=``]]
[[+htmlLink:notempty=`
<p>HTML link: [[+status]]</p>
`:default=``]]
<p><b><i><a href="[[~14? &cid=`[[+calendarId]]` &eid=`[[+id]]`]]" title="Detail">read more...</a></i></b></p>
</div>
</div>
Now, there is problem.
I use the Ajax's processor to parse the template.
If the placeholder has an empty value, the Output Modifier does not work.
I know there is a limitation for that.
But perhaps there is someone here can help me how to deal with this situation.
Thanks before.