mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-07 22:05:59 +01:00
Fill up title when creating a new page
This commit is contained in:
@@ -125,7 +125,7 @@ class AdminPlugin extends Plugin
|
|||||||
if ($task) {
|
if ($task) {
|
||||||
require_once __DIR__ . '/classes/controller.php';
|
require_once __DIR__ . '/classes/controller.php';
|
||||||
$controller = new AdminController($this->grav, $this->template, $task, $this->route, $post);
|
$controller = new AdminController($this->grav, $this->template, $task, $this->route, $post);
|
||||||
$success = $controller->execute();
|
$controller->execute();
|
||||||
$controller->redirect();
|
$controller->redirect();
|
||||||
} elseif ($this->template == 'logs' && $this->route) {
|
} elseif ($this->template == 'logs' && $this->route) {
|
||||||
// Display RAW error message.
|
// Display RAW error message.
|
||||||
|
|||||||
@@ -389,19 +389,21 @@ class Admin
|
|||||||
$page = new Page;
|
$page = new Page;
|
||||||
$page->parent($parent);
|
$page->parent($parent);
|
||||||
$page->filePath($parent->path().'/'.$slug.'/'.$page->name());
|
$page->filePath($parent->path().'/'.$slug.'/'.$page->name());
|
||||||
$page->header();
|
|
||||||
|
|
||||||
// Add routing information.
|
// Add routing information.
|
||||||
$pages->addPage($page, $path);
|
$pages->addPage($page, $path);
|
||||||
|
|
||||||
// Determine page type.
|
// Determine page type.
|
||||||
if (isset($this->session->{$page->route()})) {
|
if (isset($this->session->{$page->route()})) {
|
||||||
// Found the type from the session.
|
// Found the type and header from the session.
|
||||||
$page->name($this->session->{$page->route()} . '.md');
|
$data = $this->session->{$page->route()};
|
||||||
|
$page->name($data['type'] . '.md');
|
||||||
|
$page->header(['title' => $data['title']]);
|
||||||
} else {
|
} else {
|
||||||
// Find out the type by looking at the parent.
|
// Find out the type by looking at the parent.
|
||||||
$type = $parent->child_type() ? $parent->child_type() : $parent->blueprints()->get('child_type', 'default');
|
$type = $parent->child_type() ? $parent->child_type() : $parent->blueprints()->get('child_type', 'default');
|
||||||
$page->name($type.CONTENT_EXT);
|
$page->name($type.CONTENT_EXT);
|
||||||
|
$page->header();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -250,13 +250,12 @@ class AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->post;
|
$data = $this->post;
|
||||||
$route = $data['route'];
|
$route = $data['route'] != '/' ? $data['route'] : '';
|
||||||
$folder = $data['folder'];
|
$folder = $data['folder'];
|
||||||
$type = $data['type'];
|
|
||||||
$path = $route . '/' . $folder;
|
$path = $route . '/' . $folder;
|
||||||
|
|
||||||
$this->admin->session()->{$path} = $type;
|
$this->admin->session()->{$path} = $data;
|
||||||
$this->setRedirect($this->view . '/' . $path);
|
$this->setRedirect("{$this->view}/{$path}");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user