modResource.duplicate
Last updated not available | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodResource.duplicate¶
Creates a copy of the Resource with a fresh ID. The pagetitle is kept unless newName or prefixDuplicate is given, and publication fields follow publishedMode. Template Variable values and Resource Group memberships are copied too.
Returns the new modResource, the resource_err_duplicate lexicon string when the copy cannot be saved, or false outside modX. Children are duplicated recursively unless duplicateChildren is disabled; recursion stops when the user lacks the add_children policy.
Syntax¶
mixed duplicate ([array $options = array()])
-
newName(string) pagetitle for the copy -
prefixDuplicate(boolean) prefix the pagetitle with theduplicate_oflexicon entry -
publishedMode(string)preserve(default),publishorunpublish -
overrides(array) field values merged into the copy -
parent(int) parent of the copy, by default the same parent -
preserve_alias(boolean) keep the original alias instead of rebuilding it, by defaultfalse -
preserve_menuindex(boolean) keep the original menuindex instead of appending, by defaultfalse -
global_duplicate_uri_check(boolean) check alias uniqueness across all contexts, by defaultfalse -
duplicateChildren(boolean) duplicate descendants as well, by defaulttrue
Example¶
$resource = $modx->getObject('modResource', array('id' => 5));
$copy = $resource->duplicate(array(
'newName' => 'foobar copy',
'publishedMode' => 'unpublish',
));
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










