From dad43f4a1948e5ed8448fd7d06c8bd8722e17ffa Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 3 Jan 2022 16:52:55 -0800 Subject: [PATCH] pages marked as menu items render as non-blog pages --- brain/controller/IndexControl.inc.php | 16 ++++++++++++---- brain/data/Render.inc.php | 12 +++++++++--- brain/utility/Sorting.inc.php | 6 +++++- content/themes/fipamo-default/frame.twig | 6 +++--- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/brain/controller/IndexControl.inc.php b/brain/controller/IndexControl.inc.php index e8c7d5e..615c4e6 100644 --- a/brain/controller/IndexControl.inc.php +++ b/brain/controller/IndexControl.inc.php @@ -63,17 +63,24 @@ class IndexControl break; default: - //check layout to see what page should be rendered - $template = $settings["global"]["theme"] . "/page.twig"; + //check if page is a menu item, if not render along path as usual + $page = []; $book = new Book(); - $page = $book->findPageBySlug($args["third"]); + if (is_numeric($args["first"])) { + $page = $book->findPageBySlug($args["third"]); + } else { + $page = $book->findPageBySlug($args["first"]); + } + $template = + $settings["global"]["theme"] . "/" . $page["layout"] . ".twig"; $pageOptions = Sorting::page($page); break; } } else { //index - $template = $settings["global"]["theme"] . "/index.twig"; + $template = + $settings["global"]["theme"] . "/" . $page["layout"] . ".twig"; $book = new Book(""); $page = $book->findPageBySlug(); $pageOptions = Sorting::page($page); @@ -83,6 +90,7 @@ class IndexControl $response->getBody()->write($html); return $response; } else { + //if dynamic flag is false, load up html $view = Twig::fromRequest($request); $html = file_get_contents("../public/index.html"); $response->getBody()->write($html); diff --git a/brain/data/Render.inc.php b/brain/data/Render.inc.php index 251cd30..e3b745d 100644 --- a/brain/data/Render.inc.php +++ b/brain/data/Render.inc.php @@ -80,9 +80,15 @@ class Render $location = "../public/index.html"; $dir = null; } else { - $location = - "../public/" . $page["path"] . "/" . $page["slug"] . ".html"; - $dir = "../public/" . $page["path"]; + // if page is a menu item, render the page on public root + if ($page["menu"] == "true") { + $location = "../public/" . $page["slug"] . ".html"; + $dir = "../public/"; + } else { + $location = + "../public/" . $page["path"] . "/" . $page["slug"] . ".html"; + $dir = "../public/" . $page["path"]; + } } $html = $this->twig->render($template, $pageOptions); diff --git a/brain/utility/Sorting.inc.php b/brain/utility/Sorting.inc.php index 0c7b3d5..475a0ca 100644 --- a/brain/utility/Sorting.inc.php +++ b/brain/utility/Sorting.inc.php @@ -181,7 +181,11 @@ class Sorting $limit = 4; $pages = (new Book())->getContents(); foreach ($pages as $item) { - if (!$item["deleted"] && $item["published"]) { + if ( + !$item["deleted"] && + $item["published"] && + $item["menu"] != "true" + ) { if (count($recent) < $limit) { array_push($recent, [ "path" => $item["path"], diff --git a/content/themes/fipamo-default/frame.twig b/content/themes/fipamo-default/frame.twig index caa32fc..d16faa3 100644 --- a/content/themes/fipamo-default/frame.twig +++ b/content/themes/fipamo-default/frame.twig @@ -36,12 +36,12 @@ {% for link in menu %} {% if dynamicRender is defined %} {% if dynamicRender == 'true' %} - {{link.title}}
+ {{link.title}}
{% else %} - {{link.title}}
+ {{link.title}}
{% endif %} {% else %} - {{link.title}}
+ {{link.title}}
{% endif %} {% endfor %}