We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25663 MODX Staff
    • 12,272 Posts
    Can anyone confirm if the API code for any of the getTemplateVar/s/Output actually works... I've been beating my head against this all day with the following type of scenario:

    Doc id 102 has a TV assigned to it via its template called "propertyLocation".

    propertyLocation of doc 102 = "Dallas, TX"

    The following code per the instructions in the documentation does not return anything as expected:
    $pid = 102;
    
    $result = $modx-> getTemplateVars('*');
    for ($i=0;$i<count($result);$i++) {
    	$o.= $result[$i]['name']. ' = ' . $result[$i]['value'].'<br />';
    }
    
    
    $result2 = $modx->getTemplateVarOutput(array('propertyLocation'));
    
    return 'result: '.$o.'<br />'.$result2['propertyLocation'];
    
    


    It should return a key=>value pair plus the value in the propertyLocation TV, but it only returns emptiness:
    | result: =
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =

      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 25663 MODX Staff
      • 12,272 Posts
      update, adding the following to the code:
      $result3 = $modx->getDocument($pid);
      
      return 'result: '.$o.'<br />'.$result2['propertyLocation'].'<br />'.$result3['pagetitle'];


      results in the addition of the following last line as expected, so I think it's a problem with the getTemplateVars API code:
      | result: =
      =
      =
      =
      =
      =
      =
      =
      =
      =
      =
      =


      6060 North Central Expressway
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 25663 MODX Staff
        • 12,272 Posts
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 26085
          • 494 Posts
          Quote from: rthrash at May 04, 2005, 11:20 PM

          Resolved here

          I sow just
          Etomite encountered the following error while attempting to parse the requested resource:
          « Redirection attempt failed - please ensure the document you’re trying to redirect to exists. Redirection URL: 16.html »
            • 10449
            • 956 Posts
            I’m using something like this in a snippet and it works (0.9.6.1):

            	$tv = $modx->getTemplateVarOutput('pfClientName', $pid);
            	$o = $tv['pfClientName'];
            	return $o;
            
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: SamZ at Dec 08, 2007, 04:21 AM

              I sow just
              Etomite encountered the following error while attempting to parse the requested resource:
              « Redirection attempt failed - please ensure the document you’re trying to redirect to exists. Redirection URL: 16.html »

              SamZ: it was an old outdated link; I corrected the original link in the post.
                • 26085
                • 494 Posts
                tanks