$tv = $doc->getTVValue('docCount');$tv = $doc->getTVValue(4); // 4 is the ID of the TV, not the doc
$tv = $modx->getObject('modTemplateVar', array('name'=>'MyTv'));
$tv->setValue($id,'SomeValue'); // $id is the ID of the doc where you want to change the TV , not the TV
That’s because it should be this:
// get the TV docCount in the current doc $tv = $modx->getObject('modTemplateVar',array('name'=>'docCount')); // Add 1 to the value of docCount and call it newValue: $newValue = $modx->resource->getTVValue('docCount') + 1; // Set the tv docCount with new value $tv->setValue($modx->resource->get('id'), $newValue); $tv->save();
$tvconv = $modx->getObject('modTemplateVar',array('name'=>'row-of-numbers'));
$newValue = $modx->resource->getTVValue('row-of-numbers');
array_push($newValue,"17");
$tvconv->setValue($modx->resource->get('id'), $newValue);
$tvconv->save();$tvconv = $modx->getObject('modTemplateVar',array('name'=>'mytv'));
$rawValue = $tvconv->getValue($idoftheotherresource);
$newvalue = $rawValue + 3;
$tvconv->setValue('mytv', $newValue);
$tvconv->save();$tvconv->setValue($idoftheotherresource, $newValue);
$tvconv = $modx->getObject('modTemplateVar',array('name'=>'mytv'));
$rawValue = $tvconv->getValue($idoftheotheresource);
$newvalue = $rawValue + 3;
$tvconv->setValue($idoftheotheresource, $newValue);
$tvconv->save();$tvconv->setValue($idoftheotheresource, $newValue);
$tvconv->setValue($idoftheotheresource, '19');
$newvalue = $rawValue + 3;
array_push($newValue,"17");