Blog Sections Open
Querying Resources by TV Value with xPDO in Evolution CMS
How to query Evolution resources by a TV value with `newQuery()`, `innerJoin()`, and `modTemplateVarResource`.
When you need more control than a frontend snippet provides, it is often easier to query Evolution CMS resources directly through xPDO. A common requirement is to fetch all resources whose template variable matches a specific value.
The original query pattern used an inner join against modTemplateVarResource:
$criteria = $modx->newQuery('modResource');
$criteria->innerJoin('modTemplateVarResource','TV', 'TV.contentid = modResource.id and TV.tmplvarid=20');
$criteria->where(array(
'published' => 1,
'deleted' => 0,
'template' => 6,
'TV.value' => ''
));
The useful part here is not just the join itself, but the mental model: TVs do not live on the resource row, so filtering by TV means joining the TV value table deliberately and targeting the exact TV ID you care about.
Once that is clear, you can count matching resources, fetch collections, sort them, or extend the condition set for more complex data-driven screens. It is a strong pattern for custom listings, dashboards, cleanup scripts, and migration utilities.
Handling Multiple File Uploads in eForm for Evolution CMS
What to change when a single-file eForm workflow needs to accept several uploaded files in one submission.
Validating Uploaded File Size in eForm Before Accepting the File
How to add a custom eForm validation rule that rejects uploaded files once they exceed the allowed size.