$resource = array( "pagetitle" => 'title text', 'alias' => 'aliastext', "introtext" => 'teaser text', "content" => 'content string', "published" => 0, "tvs" => true, "tv1" => 'imagepath.jpg' ); if ($update = $modx->getObject('modResource',array("pagetitle"=>$resource['pagetitle']))) { $id = $update->get('id'); $resource['id'] = $id; $response = $modx->runProcessor('resource/update', $resource); unlink(MODX_CORE_PATH.'cache/resource/web/resources/'.$update->get('id').'cache.php'); } else { $response = $modx->runProcessor('resource/create', $resource); } if ($response->isError()) { return $response->getMessage(); }else{ echo 'supposedly it worked'; }
if ($response = $modx->runProcessor('resource/update', $resource)){ // run some code here }
This question has been answered by claytonk. See the first response.
'I'm a dumbass'
"I'm a dumbass"
$modx->runProcessor('resource/update', array('id'=>4,'pagetitle'=>'new title'));