diff --git a/code/CMSMain.php b/code/CMSMain.php index 3a974693..4edceb63 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -1167,6 +1167,12 @@ HTML; $page = DataObject::get_by_id("SiteTree", $id); $newPage = $page->duplicate(); + + // ParentID can be hard-set in the URL. This is useful for pages with multiple parents + if($_GET['parentID'] && is_numeric($_GET['parentID'])) { + $newPage->ParentID = $_GET['parentID']; + $newPage->write(); + } return $this->returnItemToUser($newPage); } else { diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index e62b1adb..6b582386 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -190,7 +190,13 @@ TreeNodeAPI.prototype = { } }, duplicatePage: function() { - new Ajax.Request(baseHref() + 'admin/duplicate/' + this.getIdx() + '?ajax=1', { + // Pass the parent ID to the duplicator, which helps ensure that multi-parent pages are duplicated into the node that the user clicked + var parentClause = ""; + if(this.parentTreeNode && this.parentTreeNode.getIdx) { + parentClause = "&parentID=" + this.parentTreeNode.getIdx(); + } + + new Ajax.Request(baseHref() + 'admin/duplicate/' + this.getIdx() + '?ajax=1' + parentClause, { method : 'get', onSuccess : Ajax.Evaluator, onFailure : function(response) {