We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello,
    I'm using MIGX for Revo 2.2. I'd like to add items to the MIGX TV programmatically. Is this possible?
    Thanks in advance for your help.
      • 4172
      • 5,888 Posts
      something like that should work:

      <?php
      
      $newitem['image'] = 'test.jpg';
      $newitem['title'] = 'myTitle';
      
      
      if ($resource = $modx->getObject('modResource', $resourceID)) {
          $oldvalue = $resource->getTvValue($tvname);
          $items = $modx->fromJson($oldvalue);
      
          if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
              
              $items[] = $newitem; 
              $tv->setValue($resourceID, $modx->toJson($items));
              $tv->save();
          }
      }
      
      [ed. note: Bruno17 last edited this post 14 years, 10 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8425
        • 159 Posts
        Thanks for your help!