Quote from: hgw at Jan 15, 2010, 01:44 PM
Hello,
in a snippet I need the value of a TV of the same document. The name of the TV is ’NumberOfQuestions’. The input type of the TV is ’number’. I tried some versions i.E.:
$Number = $modx->getTemplateVarOutput('NumberOfQuestions');
It’s expecting an array for the first argument so it should be:
$Number = $modx->getTemplateVarOutput(array('NumberOfQuestions'));
BobRay is right, I’d like to mention that the function call result is also an array:
$r = $modx->getTemplateVarOutput(array(’NumberOfQuestions’,$modx->documentIdentifier);
$Number = $r[’NumberOfQuestions’];
There is another way to do this too:
$r = $modx->getTemplateVar("NumberOfQuestions",’name’,$modx->documentIdentifier);
$Number = $r[’value’];
I’ve not dug into the core code yet, but guessing from their names, getTemplateVarOuput might do some extra work by formatting those complicated TVs (e.g. image) from raw value to display so the second method might be slightly faster though it’s parameters are much more from obvious than the first one.
Thanks, it was a great help, if got it to work now.