$query = "SELECT contentid FROM modx_site_tmplvar_contentvalues WHERE (tmplvarid='" . $abc . "' AND value='" . $def . "')"; $result = $modx->query($query);
$x = $modx->getObject('modResource', $id);
$x->geTVValue('tvname');

$modx->getObject('modTemplateVar', array (
'id' => $x,
'name' => 'tvname',
))Getting the value of a TV in another document is a little more tricky because the processed value of the TV can be different for each document it's embedded in. As a result, you have to either get the resource object using the method above, or use specific methods of the TV and send along the ID of the document. Assuming that $id is the ID of the document (not the TV):[ed. note: sottwell last edited this post 13 years ago.]
/* Get the TV */
$tv = $modx->getObject('modTemplateVar',array('name'=>'MyTV'));
/* get the raw content of the TV */
$rawValue = $tv->getValue($id);
/* get the processed content of the TV */
$processedValue = $tv->renderOutput($id);
