I can do with some help if possible.
I can’t for the life of me figure out why when running a PUT command on TV fields they don’t update.
Current code which lists the TVs
Any help would be greatly appreciated.
Thanks
<? class MyControllerItems extends modRestController {
public $classKey = 'modResource';
public $defaultSortField = 'id';
public $defaultSortDirection = 'ASC';
public function read($id) {
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns',array(
'field' => $this->primaryKeyField,
)));
}
/** @var xPDOObject $object */
$c = $this->getPrimaryKeyCriteria($id);
$this->object = $this->modx->getObject($this->classKey,$c);
if (empty($this->object)) {
return $this->failure($this->modx->lexicon('rest.err_obj_nf',array(
'class_key' => $this->classKey,
)));
}
$tv = $this->modx->getObject('modTemplateVarResource', array('tmplvarid' => $tvID, 'contentid' => $id));
$objectArray = Array();
$objectArray ['id'] = $id;
$objectArray ['pagetitle'] = $this->object->pagetitle;
$objectArray ['alias'] = $this->object->alias;
$objectArray['welcome-message'] = $this->object->getTVValue(20);
$afterRead = $this->afterRead($objectArray);
if ($afterRead !== true && $afterRead !== null) {
return $this->failure($afterRead === false ? $this->errorMessage : $afterRead);
}
return $this->success('',$objectArray);
}
}
?>