diff --git a/README.md b/README.md index f1ade979..9a96f29c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ For **bugs, features, improvements**, please ensure you [create issues in the ad # Installation +First ensure you are running the latest **Grav 0.9.34 or later**. This is required for the admin plugin to run properly (`-f` forces a refresh of the GPM index). + +``` +$ bin/gpm selfupgrade -f +``` + The admin plugin actually requires the help of 3 other plugins, so to get the admin plugin to work you first need to install **admin**, **login**, **forms**, and **email** plugins. These are available via GPM, and because the plugin has dependencies you just need to proceed and install the admin plugin, and agree when prompted to install the others: ``` diff --git a/classes/admin.php b/classes/admin.php index 0fa625b1..74243018 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -504,7 +504,7 @@ class Admin // Found the type and header from the session. $data = $this->session->{$page->route()}; $page->name($data['type'] . '.md'); - $page->header(['title' => $data['title']]); + $page->header(['title' => $data['title'], 'visible' => $data['visible']]); $page->frontmatter(Yaml::dump((array) $page->header())); } else { // Find out the type by looking at the parent. diff --git a/classes/controller.php b/classes/controller.php index e010b9b9..0802eaa0 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -778,6 +778,7 @@ class AdminController return; } + $reorder = false; $data = $this->post; // Special handler for pages data. @@ -796,6 +797,20 @@ class AdminController $obj = $obj->move($parent); $this->preparePage($obj); + // rename folder based on visible + if (isset($data['header']['visible'])) { + if ($data['header']['visible'] && !$obj->order()) { + // needs to have order set + $obj->order(1000); + $obj->header['visible'] = null; + $reorder = true; + } elseif (!$data['header']['visible'] && $obj->order()) { + // needs to have order removed + $obj->folder($obj->slug()); + $reorder = true; + } + } + // Reset slug and route. For now we do not support slug twig variable on save. $obj->slug($original_slug); @@ -806,7 +821,7 @@ class AdminController if ($obj) { $obj->validate(); $obj->filter(); - $obj->save(); + $obj->save($reorder); $this->admin->setMessage('Successfully saved', 'info'); }