Hello,
I’m attempting to output datas and parse them into templates (chunks) before displaying, with revo beta 5 api.
Here is my buggy attempt to adapt the sample from documentation :
$resources = $modx->getCollection('modResource',array('published' => 1,));
$rowChunk = $modx->getChunk('tplEntries');
foreach ($resources as $resource) {
$properties = $resource->toArray();
$properties['rowCls'] = 'test';
$output .= $rowChunk->process($properties);
}
In the original sample it doesn’t store any resource in a variable. It retrieves datas, and basta, like this :
In my case, before performing a foreach, I store the datas in $resources :
$resources = $modx->getCollection('modResource',array('published' => 1,)); )
This causes an error when calling process() afterwards.
When removing $resources (as in sample) it doesn’t output any error now but how do I loop through values ( because without array, foreach won’t loop) :
$modx->getCollection('modResource',array('published' => 1,)); )
foreach ($resources as $resource) {
// stuff here will never be executed
}
Any clue would be greatly appreciated