Fix redirect after saving page

This commit is contained in:
Flavio Copes
2015-12-29 19:31:02 +01:00
parent c1af35e9ac
commit 52ae7bcf80

View File

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