This question has been answered by BobRay. See the first response.
<?php
/************
Return resource id based on TV value.
Example: [[!parentIds? &varName=`propertyID` &varValue=`[[+propertycode]]`]]
************/
$c = $modx->newQuery('modResource');
$c->innerJoin('modTemplateVarResource','TemplateVarResources');
$c->innerJoin('modTemplateVar','TemplateVar','TemplateVarResources.tmplvarid = TemplateVar.id');
$c->where(array(
'TemplateVar.name' => $varName,
'TemplateVarResources.value' => $varValue,
));
foreach($modx->getCollection('modResource',$c) as $res) {
$id = $res->get('id');
}
($id ? $url = $modx->makeUrl($id) : '');
return $url;[[!parentIds? &varValue=`[[+propertycode]]`]]
$tvId = 12; /* set to ID of the PropertyId TV */
$varValue = $modx->getOption('varValue', $scriptProperties);
$res = $modx->getObject('modTemplateVarResource', array('tmplvarid' => $tvId, 'value' => $varValue));
return $res? $modx->makeUrl($res->get('contentid'), "", "", "full"): '';
$tvId = 12; /* set to ID of the PropertyId TV */
$varValue = $modx->getOption('varValue', $scriptProperties);
$query = $modx->newQuery('modTemplateVarResource', array(
'value' => $varValue,
'tmplvarid' => $tvId,
));
$query->select('contentid');
$docId = $modx->getValue($query->prepare());
return $docId? $modx->makeUrl($docId, "", "", "full") : '';
$tvId = $modx->getOption('tvId', $scriptProperties); $varValue = $modx->getOption('varValue', $scriptProperties);$res = $modx->getObject('modTemplateVarResource', array('tmplvarid' => $tvId, 'value' => $tvValue));
return $res? $modx->makeUrl($res->get('contentid'), "", "", "full"): '';
http://bobsguides.com/blog.html/2014/08/14/understanding-the-modx-getoption()-method/