
This question has been answered by Jako. See the first response.
$count = 0;
$docArray = $modx->getIterator('modResource',array(
'parent' => 42,
));
foreach($docArray as $doc) {
$docid = $doc->get('id');
$tv = $modx->getObject('modTemplateVar',array('name'=>'MyTV'));
$rawValue = $tv->getValue($id);
if(isset($rawValue)) count++;
}
return $count;
$total = $modx->getCount('modTemplateVarResource', array('tmplvarid' => $tvID, 'value' != $value));
return $total;[[!tvValueCount? &tvId=`2` &value=``]]
$total = $modx->getCount('modTemplateVarResource', array('tmplvarid' => $tvID, 'value' != $value, 'contentid:IN' => $child_ids));
return $total;get the child_ids of the parent in an array first....

[[!tvValueCount? &tvId=`2` &parentId=`12` &value=``]]
$parentId = $modx->getOption('parentId', $scriptProperties, '');
$tvId = $modx->getOption('tvId', $scriptProperties, '');
if (empty($parentId)) {
return 'No Parent Id Set';
}
if (empty($tvId)) {
return 'No TV Id Set';
}
$childIds = $modx->getChildIds($parentId);
$total = $modx->getCount('modTemplateVarResource', array('tmplvarid' => $tvId, 'value' != $value, 'contentid:IN' => $childIds));
return $total;$childIds = $modx->getChildIds($parentId);