updating menu items in settings when pages is saved
This commit is contained in:
parent
20cc4abad9
commit
594df048cf
2 changed files with 28 additions and 0 deletions
|
@ -183,6 +183,9 @@ class Book
|
||||||
if ($task == "create") {
|
if ($task == "create") {
|
||||||
Settings::updateIndex();
|
Settings::updateIndex();
|
||||||
}
|
}
|
||||||
|
//once saved, update menu
|
||||||
|
$body["path"] = $path;
|
||||||
|
Settings::updateMenu($body);
|
||||||
} else {
|
} else {
|
||||||
$response = [
|
$response = [
|
||||||
"message" => "Uh oh. File save problem. Don't panic",
|
"message" => "Uh oh. File save problem. Don't panic",
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use function _\find;
|
use function _\find;
|
||||||
|
use function _\pull;
|
||||||
|
use function _\remove;
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
private $folks;
|
private $folks;
|
||||||
|
@ -89,4 +91,27 @@ class Settings
|
||||||
|
|
||||||
DocTools::writeSettings("../config/settings.json", $settings);
|
DocTools::writeSettings("../config/settings.json", $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function updateMenu($body)
|
||||||
|
{
|
||||||
|
$settings = self::$settings;
|
||||||
|
//$menu = $settings["menu"];
|
||||||
|
$item = [
|
||||||
|
"title" => $body["title"],
|
||||||
|
"id" => $body["id"],
|
||||||
|
"uuid" => $body["uuid"],
|
||||||
|
"slug" => $body["slug"],
|
||||||
|
"path" => $body["path"],
|
||||||
|
];
|
||||||
|
if ($body["menu"] == "true") {
|
||||||
|
if (!find($settings["menu"], ["uuid" => $item["uuid"]])) {
|
||||||
|
array_push($settings["menu"], $item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (find($settings["menu"], ["uuid" => $item["uuid"]])) {
|
||||||
|
pull($settings["menu"], $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DocTools::writeSettings("../config/settings.json", $settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue