modResource.duplicate
Last updated Oct 11th, 2026 | 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 copyprefixDuplicate(boolean) prefix the pagetitle with theduplicate_oflexicon entrypublishedMode(string)preserve(default),publishorunpublishoverrides(array) field values merged into the copyparent(int) parent of the copy, by default the same parentpreserve_alias(boolean) keep the original alias instead of rebuilding it, by defaultfalsepreserve_menuindex(boolean) keep the original menuindex instead of appending, by defaultfalseglobal_duplicate_uri_check(boolean) check alias uniqueness across all contexts, by defaultfalseduplicateChildren(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










