diff --git a/brain/controller/DashControl.inc.php b/brain/controller/DashControl.inc.php index 6a5d350..1c26877 100644 --- a/brain/controller/DashControl.inc.php +++ b/brain/controller/DashControl.inc.php @@ -104,14 +104,20 @@ class DashControl $uuid = $args["fourth"]; switch ($mode) { case "edit": - $customPages = (new Themes())->getCustomViews(); + $page = (new Book("../content/pages"))->findPageById($uuid); + $views = []; + if (str_contains($page["layout"], "index")) { + $views = (new Themes())->getCustomIndex(); + } else { + $views = (new Themes())->getCustomViews(); + } $pageOptions = [ "title" => "Fipamo | Edit Page", - "page" => (new Book("../content/pages"))->findPageById($uuid), + "page" => $page, "mode" => $mode, "token" => Session::get("form_token"), "status" => Session::active(), - "views" => $customPages, + "views" => $views, ]; break; case "preview": diff --git a/brain/data/Themes.inc.php b/brain/data/Themes.inc.php index fbfe4a8..6ad02fb 100644 --- a/brain/data/Themes.inc.php +++ b/brain/data/Themes.inc.php @@ -20,6 +20,25 @@ class Themes return $this->themes; } + public function getCustomIndex() + { + $settings = (new Settings())->getSettings(); + $currentTheme = $settings["global"]["theme"]; + $folder = "../content/themes/" . $currentTheme; + $files = array_filter(glob("$folder/*twig"), "is_file"); + $views = []; + + foreach ($files as $file) { + $path = explode("/", $file); + $fileName = $path[4]; + if (str_contains($fileName, "index")) { + $page = explode(".", $fileName); + $views[] = $page[0]; + } + } + return $views; + } + public function getCustomViews() { $settings = (new Settings())->getSettings();