Here is the code for Duplicate resource in modx revolution :
$oldResource = $modx->getObject('modResource',RESOURCE_ID); // set resource id from which you want to Duplicate resource
if (empty($oldResource)) return $modx->error->failure($modx->lexicon('resource_err_nfs',array('id' => $props['resourceID'])));
if (!$oldResource->checkPolicy('copy')) {
return $modx->error->failure($modx->lexicon('permission_denied'));
}
/* get parent */
$parent = $cat;
$newResource = $oldResource->duplicate(array(
'newName' => NEW_TITLE, // New Title which you want to see in new resource
));
if (!($newResource instanceof modResource)) {
return $newResource;
}
$modx->invokeEvent('OnResourceDuplicate',array(
'newResource' => &$newResource,
'oldResource' => &$oldResource,
));
Comment it and Share it if it helps you.
$oldResource = $modx->getObject('modResource',RESOURCE_ID); // set resource id from which you want to Duplicate resource
if (empty($oldResource)) return $modx->error->failure($modx->lexicon('resource_err_nfs',array('id' => $props['resourceID'])));
if (!$oldResource->checkPolicy('copy')) {
return $modx->error->failure($modx->lexicon('permission_denied'));
}
/* get parent */
$parent = $cat;
$newResource = $oldResource->duplicate(array(
'newName' => NEW_TITLE, // New Title which you want to see in new resource
));
if (!($newResource instanceof modResource)) {
return $newResource;
}
$modx->invokeEvent('OnResourceDuplicate',array(
'newResource' => &$newResource,
'oldResource' => &$oldResource,
));
Comment it and Share it if it helps you.
No comments:
Post a Comment