fix for #72, index page not using page themes
This commit is contained in:
parent
39775e624d
commit
f119bdc773
2 changed files with 28 additions and 3 deletions
|
@ -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…
Reference in a new issue