Assign the correct parent when copying a page

This commit is contained in:
Flavio Copes
2015-08-03 17:07:12 +02:00
parent 319b7a3963
commit 5b3f11be7e

View File

@@ -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);