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.
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.]