<?php
//config
$templateId = 9;
$limit = 500;
$offset = 0;
$contextResourceTbl = $modx->getTableName('modContextResource');
$context = empty($context) ? $modx->quote($modx->context->get('key')) : $modx->quote($context);
$criteria = $modx->newQuery('modResource', array(
'deleted' => '0'
,'published' => '1'
,'isfolder' => '0'
,"`modResource`.`template` = {$templateId}"
///I have no clue how to use contexts.
,"(`modResource`.`context_key` = {$context} OR EXISTS(SELECT 1 FROM {$contextResourceTbl} `ctx` WHERE `ctx`.`resource` = `modResource`.`id` AND `ctx`.`context_key` = {$context}))"
));
$criteria->limit($limit, $offset);
if (!empty($debug)) {
$criteria->prepare();
$modx->log(modX::LOG_LEVEL_ERROR, $criteria->toSQL());
}
$collection = $modx->getCollection('modResource', $criteria);
foreach ($collection as $resourceId => $resource) {
//this loops through the resources
//$resource->get('id'); //maybe $resource->id
//$resource->pagetitle;
}
?>
[[!If?
&subject=`[[+template]]`
&operator=`EQ`
&operand=`4`
&then=`
Output my content with template id '4'.
`
]]
[[!getResources? &parents=`[[*id]]` &limit=`3` &tpl=`news` &includeContent=`1` &includeTVs=`1` ]]
[[!getResources?
&tpl=`flexslider_tpl`
&tplFirst=`flexslider_tplFirst`
&tplLast=`flexslider_tplLast`
&includeTVs=`1`
&processTVs=`0`
&where=`{"template:=":3}`
&tvPrefix=``
&limit=`0`
]]