<![CDATA[ How to use templatevar output in snippet - MODX Community Forums]]> https://forums.modx.com/thread/?thread=4168 <![CDATA[Re: How to use templatevar output in snippet]]> https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25136
for($i=0;$i<count($result);$i++) {
	$row = $result[$i];
	$output[$row['name']] = getTVDisplayFormat($this,$row['name'],$row['value'],$row['display'],$row['display_params'],$row['type']);
}


Give it a try]]>
xwisdom May 30, 2005, 10:12 PM https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25136
<![CDATA[Re: How to use templatevar output in snippet]]> https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25135 Quote from: xwisdom at May 30, 2005, 08:48 PM


That could be true opengeek smiley If it is then just remove it and let me know.

Thanks


Unfortunately, I tried using the real value and hardcoding it to true and still could not get it to go through the getTVDisplayFormat() function.]]>
opengeek May 30, 2005, 03:55 PM https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25135
<![CDATA[Re: How to use templatevar output in snippet]]> https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25134 That could be true opengeek smiley If it is then just remove it and let me know.

Thanks
]]>
xwisdom May 30, 2005, 03:48 PM https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25134
<![CDATA[How to use templatevar output in snippet]]> https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25133
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. grin]]>
opengeek May 30, 2005, 12:06 PM https://forums.modx.com/thread/4168/how-to-use-templatevar-output-in-snippet#dis-post-25133