fix for #72, index page not using page themes

This commit is contained in:
Ro 2021-12-18 11:30:41 -08:00
parent 39775e624d
commit f119bdc773
2 changed files with 28 additions and 3 deletions

View file

@ -104,14 +104,20 @@ class DashControl
$uuid = $args["fourth"]; $uuid = $args["fourth"];
switch ($mode) { switch ($mode) {
case "edit": 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 = [ $pageOptions = [
"title" => "Fipamo | Edit Page", "title" => "Fipamo | Edit Page",
"page" => (new Book("../content/pages"))->findPageById($uuid), "page" => $page,
"mode" => $mode, "mode" => $mode,
"token" => Session::get("form_token"), "token" => Session::get("form_token"),
"status" => Session::active(), "status" => Session::active(),
"views" => $customPages, "views" => $views,
]; ];
break; break;
case "preview": case "preview":

View file

@ -20,6 +20,25 @@ class Themes
return $this->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() public function getCustomViews()
{ {
$settings = (new Settings())->getSettings(); $settings = (new Settings())->getSettings();