We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32407
    • 35 Posts
    I have found that
    getObject('modTemplateVarTemplate',
    can get the what template VARs are associated with what template

    What I would like to do is get the template var content from the datbase using something like the
    getObject()
      • 3749
      • 24,544 Posts
      I’m not sure what you mean by the template var. content, but maybe this will help.

      You can get the template variable object with

      <?php
      $tv = $modx->getObject('modTemplateVar',$id); // $id = ID of the TV itself
      
      // or
      
      $tv = $modx->getObject('modTemplateVar',array('name'=>'MyTV'));
      


      Then these will get various values:

      <?php
      $v = $tv->getContent();  // for the default value of the TV itself.
      $v = $tv->getValue(12);  // for the raw value of the TV in doc 12
      $v = $tv->getValue($modx->resource->get('id')); // for the raw value of the TV in the current doc.
      $v = $tv->renderOutput(12); // for the processed value of the TV in doc 12.
      $v = $tv->renderOutput($modx->resource->get('id')); // for the processed value of the TV in the current doc.


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting