From 584481c100d5d9e9b784193bd6f285f6d79d0e52 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 19 Nov 2007 01:20:05 +0000 Subject: [PATCH] parents-merge 33200 - Fix duplicate page with multiple parents git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@45044 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 6 ++++++ javascript/LeftAndMain_left.js | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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) {