We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14349
    • 44 Posts
    In my snippet that creates a new modx object I can easily edit/set the different default fields
    $product = $modx->newObject('modResource');
      $product->set('pagetitle',$p_name); 



    BUT how would I do this with a template variable - I know how to get the raw and processed values from a TV but setting them.

    Would this be something more easily accomplished by working with the XML scheme with new fields ?


    *edit Revolution API reference shows modTemplateVar having a setValue method - is this what i’m looking for
      • 1778
      • 659 Posts
      Hello,
      $tv = $modx->getObject('modTemplateVar',array('name'=>'Color'));
      $tv->setValue($docID, $newValue);
      $tv->save();
      

      This might helps
      Cheers