We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20546
    • 74 Posts
    Hi there,

    Does anyone know how to set a Document (Resource) TemplateVariable-Value with a Snippet in Revolution RC-1?
    I can read it with:
    $modx->resource->getTVValue('tvtest1');

    But is there something similar like e.g. setTVValue?

    Thanks
      • 3749
      • 24,544 Posts
      Close. wink

      It’s a method of the TV, though, not the resource.

      I think this is how it’s supposed to work (I was having trouble with it today, so YMMV).

      You have to get the TV first, then set it:

      $tv = $modx->getObject('modTemplateVar', array('name=>'TvName'));
      $id =12;  /* id of the resource whose TV you want to change */
      $tv->setValue($id, 'newValue');
      $tv->save();
      


        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
        • 20546
        • 74 Posts
        Thanks a lot, it works fine!