I’m not sure where this Evo question belongs, so admin can move it around as they see fit.
My question regards getting at template variable contents. I’m wanting to use the contents of a TV to populate a dropdown list (and eventually checkboxes, radio boxes, etc.) for use with a Ditto call. The specific example I’m following is found here
http://kunane.com/modx/ditto-multiple-filters.html
(which is a truly excellent tutorial and tutorial site, FWIW).
But instead of hardcoding the values for the form to display in a dropdown, I want to use a TV so that I know there can be no ambiguity in what values are selected on a document and what is searched. In other words, if a value gets changed in the TV then it will be reflected both in the form as well as the resources which the form/Ditto will be filtering.
The specific question crops up in the snippet used there to, for example, select a city. Instead of
$values = array('City1','City2','City3')
I found that if I assigned the TV to the document in which the search form is located I could use this approach :
$values = $modx->getTemplateVars(array("tvcity"));
$newvalues = explode( '||' , $values[0]['elements'] );
$values = array(); //just reusing the variable here
foreach ($newvalues as $key => $value)
{
$valuestemp = explode('==', $value);
if ($valuestemp[1] != '')
$values[] = $valuestemp[1];
}
($modx->getTemplateVarOutput doesn’t work because the TV is not used in this document like it is in others.)
It seems to me that I ought to more easily be able to get at a TV’s contents (not necessarily a particular value) from PHP. So I thought I’d ask - is there an easier way that anyone knows of to accomplish this?
This is for Evolution 1.0.4 ...
TIA,
Matt