Creating resources in code in MODX Revoution is fairly simple. I just happened to have the code in my clipboard.
$title = 'MyPage';
$pageAlias = 'my-page';
$templateId = 2;
$fields = array(
'pagetitle' => $title,
'template' => $templateId,
'alias' => $pageAlias,
/* other fields here as necessary. System defaults will be used if empty */
};
/* create and save new resource */
$response = $this->modx->runProcessor('resource/create', $fields);
/* optional error handling */
if ($response->isError()) {
if ($response->hasFieldErrors()) {
$fieldErrors = $response->getAllErrors();
$errorMessage = implode("\n", $fieldErrors);
} else {
$errorMessage = 'An error occurred: ' . $response->getMessage();
}
return $errorMessage;
} else {
/* optional - in case you want the ID of the new resource (e.g., for makeUrl() ) */
$object = $response->getObject();
$resourceId = $object['id'];
}
You could have to add code at the top to get the data from the other database (or export it to a CSV file and read that file).
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODx info for everyone:
http://bobsguides.com/MODx.html