Skip to content

Instantly share code, notes, and snippets.

@TrywaR
Created May 21, 2018 14:23
Show Gist options
  • Save TrywaR/bee98117d95aab150ae5e5daa7d43a71 to your computer and use it in GitHub Desktop.
Save TrywaR/bee98117d95aab150ae5e5daa7d43a71 to your computer and use it in GitHub Desktop.
[ MODX ] create doc
<?
$title = 'title';
$longtitle = 'longtitle';
$introtext = 'introtext';
$content = '';
$template = '';
$publishedon = DateTime::createFromFormat('Y-m-d', date('Y-m-d'));
$published = 0;
$parent = 31;
$response = $modx->runProcessor('resource/create', array(
'pagetitle' => $title,
'longtitle' => $longtitle,
'introtext' => $introtext,
'content' => nl2br($content),
'template' => $template,
'publishedon' => $publishedon,
'published' => $published,
'parent' => $parent));
if ($response->isError()) {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'There was a problem to create resource...');
$modx->log(xPDO::LOG_LEVEL_ERROR, $response->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment