mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-04 20:36:03 +01:00
Fix fatal error on deleting the homepage
This commit is contained in:
17
admin.php
17
admin.php
@@ -148,7 +148,12 @@ class AdminPlugin extends Plugin
|
|||||||
unset($this->grav['admin']->routes['/']);
|
unset($this->grav['admin']->routes['/']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pages->dispatch('/', true)->route($home);
|
$page = $pages->dispatch('/', true);
|
||||||
|
|
||||||
|
// If page is null, the default page does not exist, and we cannot route to it
|
||||||
|
if ($page) {
|
||||||
|
$page->route($home);
|
||||||
|
}
|
||||||
|
|
||||||
// Make local copy of POST.
|
// Make local copy of POST.
|
||||||
$post = !empty($_POST) ? $_POST : array();
|
$post = !empty($_POST) ? $_POST : array();
|
||||||
@@ -216,9 +221,13 @@ class AdminPlugin extends Plugin
|
|||||||
$twig->twig_vars['popularity'] = $this->popularity;
|
$twig->twig_vars['popularity'] = $this->popularity;
|
||||||
break;
|
break;
|
||||||
case 'pages':
|
case 'pages':
|
||||||
$twig->twig_vars['file'] = File::instance($this->admin->page(true)->filePath());
|
$page = $this->admin->page(true);
|
||||||
$twig->twig_vars['media_types'] = str_replace('defaults,', '',
|
if ($page != null) {
|
||||||
implode(',.', array_keys($this->config->get('media'))));
|
$twig->twig_vars['file'] = File::instance($page->filePath());
|
||||||
|
$twig->twig_vars['media_types'] = str_replace('defaults,', '',
|
||||||
|
implode(',.', array_keys($this->config->get('media'))));
|
||||||
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,6 +486,11 @@ class Admin
|
|||||||
|
|
||||||
if (!$page) {
|
if (!$page) {
|
||||||
$slug = basename($path);
|
$slug = basename($path);
|
||||||
|
|
||||||
|
if ($slug == '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$ppath = dirname($path);
|
$ppath = dirname($path);
|
||||||
|
|
||||||
// Find or create parent(s).
|
// Find or create parent(s).
|
||||||
|
|||||||
Reference in New Issue
Block a user