From 20ceb2cabb2076ae58985aeb3e98df8356fa11fd Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 17 Sep 2014 11:54:57 +0300 Subject: [PATCH] Fill up title when creating a new page --- admin.php | 2 +- classes/admin.php | 8 +++++--- classes/controller.php | 7 +++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/admin.php b/admin.php index d7fb8adb..f4972777 100644 --- a/admin.php +++ b/admin.php @@ -125,7 +125,7 @@ class AdminPlugin extends Plugin if ($task) { require_once __DIR__ . '/classes/controller.php'; $controller = new AdminController($this->grav, $this->template, $task, $this->route, $post); - $success = $controller->execute(); + $controller->execute(); $controller->redirect(); } elseif ($this->template == 'logs' && $this->route) { // Display RAW error message. diff --git a/classes/admin.php b/classes/admin.php index aa94fcde..3fb8f31d 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -389,19 +389,21 @@ class Admin $page = new Page; $page->parent($parent); $page->filePath($parent->path().'/'.$slug.'/'.$page->name()); - $page->header(); // Add routing information. $pages->addPage($page, $path); // Determine page type. if (isset($this->session->{$page->route()})) { - // Found the type from the session. - $page->name($this->session->{$page->route()} . '.md'); + // Found the type and header from the session. + $data = $this->session->{$page->route()}; + $page->name($data['type'] . '.md'); + $page->header(['title' => $data['title']]); } else { // Find out the type by looking at the parent. $type = $parent->child_type() ? $parent->child_type() : $parent->blueprints()->get('child_type', 'default'); $page->name($type.CONTENT_EXT); + $page->header(); } } diff --git a/classes/controller.php b/classes/controller.php index 72f2fd01..8907f30d 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -250,13 +250,12 @@ class AdminController } $data = $this->post; - $route = $data['route']; + $route = $data['route'] != '/' ? $data['route'] : ''; $folder = $data['folder']; - $type = $data['type']; $path = $route . '/' . $folder; - $this->admin->session()->{$path} = $type; - $this->setRedirect($this->view . '/' . $path); + $this->admin->session()->{$path} = $data; + $this->setRedirect("{$this->view}/{$path}"); return true; }