mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 03:46:30 +01:00
adds/removes numeric order when changing visibility status
This commit is contained in:
@@ -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:
|
||||
|
||||
```
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user