$doc->getTVValue('docCount');/*set the TV value $tv->setValue($tv, 'new value');
/*set the TV value $tv->setTVValue($tv, 'new value');
$tv->setTVValue('docCount', 'new value');Fatal error: Call to a member function setTVValue() on a non-object in www...
$doc->getTVValue('docCount');
//get the value of the TV
$tv = $doc->getTVValue('docCount');
// set the value
$tv->setTVValue('docCount', 'new value');
setTVValue('$doc->getTVValue('docCount')','new value');
// Get ID of current document:
$docID = $modx->resource->get('id');
// Get title of current document:
$docTitle = $modx->resource->get('pagetitle');
// Get the value of the TV docCount:
$doc = $modx->getObject('modResource', $docID);
//echo $doc->getTVValue('docCount');
// Add 1 to the value of docCount and call it newValue:
$newValue = $doc->getTVValue('docCount') + 1;
// get ID of the current document
$docID = $modx->resource->get('id');
// 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 = $doc->getTVValue('docCount') + 1;
// Set the tv docCount with new value
$tv->setValue($docID, $newValue);
$tv->save();
Fatal error: Call to a member function setValue() on a non-object in www....core/cache/elements/modsnippet/14.include.cache.php on line 20
// 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();
<?php
// get ID of the current document
$docID = $modx->resource->get('id');
$doc=$modx->resource;
// get the TV Color in the current doc
$tv = $modx->getObject('modTemplateVar',array('name'=>'Color'));
// Add 1 to the value of docCount and call it newValue:
$newValue = "red";
// Set the tv Color with new value
$tv->setValue($docID, $newValue);
$tv->save();
$doc->save();
?>
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();