Given a TV name or ID (could be either) I need to check whether the TV is attached to a given template. Unfortunately, I need to process the TVs one at a time.
Currently, I’m getting the array of modTemplateVarTemplates with this (which only executes once):
$c = $this->modx->newQuery('modTemplateVarTemplate');
$where = array('templateid'=>$this->template);
$c->where($where);
$tvTemplates = $this->modx->getCollection('modTemplateVarTemplate',$c);
Then I get the TV with getObject() and get its ID with $tv->get(’id);
I already know the template ID.
I walk through the array of $tvTemplate objects (actually modTemplateVarTemplate objects) and "get" the tmplvarid and the templateid of each and look for a match with the TV ID and the template ID.
It seems there should be a faster way with fewer queries.