$c = $modx->newQuery('modResource'); // or modResourceGroup?
$c->leftJoin(... //something to establish that I want to get at the templates associated with the resources
$c->where(... // where the resource uses template $x)
$resourceArray = $modx->getCollection('modResource',$c);
I’m trying to create a TV that lets you select from all published resource IDs that use a given template. I’ve tried figuring this out by looking at a few code samples, and I’m sure it is very simple. But I’m flat out lost. My best guess is
$c = $modx->newQuery('modResource'); // or modResourceGroup? $c->leftJoin(... //something to establish that I want to get at the templates associated with the resources $c->where(... // where the resource uses template $x) $resourceArray = $modx->getCollection('modResource',$c);
Could you help me get on the right track? And, is there a good resource page for various examples of working with the API to do similar things?
$c = $modx->newQuery('modResource');
$c->leftJoin('modTemplate','Template');
$c->where(array(
'published' => true,
));
if (is_numeric($template)) {
$c->where(array('template' => $template));
} else {
$c->where(array('Template.templatename' => $template));
}
$resources = $modx->getCollection('modResource',$c);