pages marked as menu items render as non-blog pages

This commit is contained in:
Ro 2022-01-03 16:52:55 -08:00
parent 7775c1d409
commit dad43f4a19
4 changed files with 29 additions and 11 deletions

View file

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

View file

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

View file

@ -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"],

View file

@ -36,12 +36,12 @@
{% for link in menu %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{"/"~link.path~"/"~link.slug}}" class="menu-link">{{link.title}}</a><br />
<a href="{{"/"~link.slug}}" class="menu-link">{{link.title}}</a><br />
{% else %}
<a href="{{"/"~link.path~"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
<a href="{{"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
{% endif %}
{% else %}
<a href="{{"/"~link.path~"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
<a href="{{"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
{% endif %}
{% endfor %}