$page = $modx->getObject('modResource', array('tv7'=>'foo')); $id = $page->get('id');
This question has been answered by Bruno17. See the first response.
// first get the ID of the page: $the_id_i_want = $modx->query( "SELECT contentid FROM modx_site_tmplvar_contentvalues WHERE tmplvarid=7 AND value='foo'" ); // then get the page itself: $row = $the_id_i_want->fetch(PDO::FETCH_ASSOC); $page = $modx->getObject('modResource', $row['contentid']);
$c = $modx->newQuery('modResource'); $c->leftjoin('modTemplateVarResource','TV','tmplvarid=7 AND contentid=modResource.id'); $c->where(array('TV.value'=>'foo')); //could maybe be more than one resource with that value if ($collection = $modx->getCollection('modResource',$c)){ foreach ($collection as $resource){ //do something with the resource-object } }