From 5b3f11be7e5c606e5ccd2507df3b9e4084fd9f1f Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 3 Aug 2015 17:07:12 +0200 Subject: [PATCH] Assign the correct parent when copying a page --- classes/controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/controller.php b/classes/controller.php index 75a31aaf..52bc3525 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -882,12 +882,12 @@ class AdminController $pages = $this->grav['pages']; $data = $this->post; - // Find new parent page in order to build the path. - $route = isset($data['route']) ? trim($data['route'], '/') : ''; - $parent = empty($route) ? $pages->root() : $pages->dispatch($data['route'], true); // And then get the current page. $page = $this->admin->page(true); + // Find new parent page in order to build the path. + $parent = $page->parent() ?: $pages->root(); + // Make a copy of the current page and fill the updated information into it. $page = $page->copy($parent); $this->preparePage($page);