From 52ae7bcf8022962f2f26fd534a537c3da8aaf250 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 29 Dec 2015 19:31:02 +0100 Subject: [PATCH] Fix redirect after saving page --- classes/controller.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/classes/controller.php b/classes/controller.php index b1348fa8..9b0db99a 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -1071,12 +1071,13 @@ class AdminController if ($this->view == 'pages') { /** @var Page\Pages $pages */ $pages = $this->grav['pages']; + $config = $this->grav['config']; // Find new parent page in order to build the path. $route = !isset($data['route']) ? dirname($this->admin->route) : $data['route']; $obj = $this->admin->page(true); - $config = $this->grav['config']; + //Handle system.home.hide_in_urls $hide_home_route = $config->get('system.home.hide_in_urls', false); if ($hide_home_route) { $home_route = $config->get('system.home.alias'); @@ -1089,7 +1090,6 @@ class AdminController } } } - $route = isset($baseRoute) ? $baseRoute : null; } @@ -1162,7 +1162,21 @@ class AdminController } } $admin_route = $this->grav['config']->get('plugins.admin.route'); - $redirect_url = '/' . ($multilang ? ($obj->language()) : '') . $admin_route . '/' . $this->view . $obj->route(); + + //Handle system.home.hide_in_urls + $route = $obj->route(); + $hide_home_route = $config->get('system.home.hide_in_urls', false); + if ($hide_home_route) { + $home_route = $config->get('system.home.alias'); + $topParent = $obj->topParent(); + if (isset($topParent)) { + if ($topParent->route() == $home_route) { + $route = (string) $topParent->route() . $route; + } + } + } + + $redirect_url = '/' . ($multilang ? ($obj->language()) : '') . $admin_route . '/' . $this->view . $route; $this->setRedirect($redirect_url); }