I’m trying to use the @SQL binding in a TV, then retrieve and use the associative array results in a snippet like such:
if (!isset($id)) { $id = $modx->documentIdentifier; }
$docInfo = $modx->getDocument($id);
$alias = $docInfo['alias'];
$out = "";
$tv = $modx->getTemplateVarOutput(array("industries"), $id);
$results = $tv["industries"];
if (is_array($results))
{
foreach ($results as $key=>$val)
{
$href = $modx->makeURL($id, $alias, "i=$key");
$out .= "<a href='$href' title='$val'>$val</a>\n";
}
}
return $out;
However, the output I’m getting from this is simply the TV definition:
<a href='index.php?id=14i=0' title='industries'>industries</a>
<a href='index.php?id=14i=1' title='@SELECT id,name FROM industries ORDER BY name ASC'>@SELECT id,name FROM industries ORDER BY name ASC</a>
<a href='index.php?id=14i=2' title=''></a>
<a href='index.php?id=14i=3' title=''></a>
<a href='index.php?id=14i=4' title='text'>text</a>
This appears to be because of this line in document.parser.class.inc.php:
$curDoc = false; // temporary hack to make it work ... Ryan Thrash
...which is preventing me from getting the formatted TV output? Seems to be a temporary hack to keep it from working.