fix for #72, index page not using page themes

pull/84/head
Ro 3 years ago
parent 39775e624d
commit f119bdc773

@ -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":

@ -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();

Loading…
Cancel
Save