We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • 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. grin
      • 32963
      • 1,732 Posts

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

      Thanks
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
      • 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.
          • 32963
          • 1,732 Posts
          Ok, try modifying the for loop inside the getTemplateVarOutput function to read:
          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
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.