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; break;
default: default:
//check layout to see what page should be rendered //check if page is a menu item, if not render along path as usual
$template = $settings["global"]["theme"] . "/page.twig"; $page = [];
$book = new Book(); $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); $pageOptions = Sorting::page($page);
break; break;
} }
} else { } else {
//index //index
$template = $settings["global"]["theme"] . "/index.twig"; $template =
$settings["global"]["theme"] . "/" . $page["layout"] . ".twig";
$book = new Book(""); $book = new Book("");
$page = $book->findPageBySlug(); $page = $book->findPageBySlug();
$pageOptions = Sorting::page($page); $pageOptions = Sorting::page($page);
@ -83,6 +90,7 @@ class IndexControl
$response->getBody()->write($html); $response->getBody()->write($html);
return $response; return $response;
} else { } else {
//if dynamic flag is false, load up html
$view = Twig::fromRequest($request); $view = Twig::fromRequest($request);
$html = file_get_contents("../public/index.html"); $html = file_get_contents("../public/index.html");
$response->getBody()->write($html); $response->getBody()->write($html);

View file

@ -80,9 +80,15 @@ class Render
$location = "../public/index.html"; $location = "../public/index.html";
$dir = null; $dir = null;
} else { } else {
$location = // if page is a menu item, render the page on public root
"../public/" . $page["path"] . "/" . $page["slug"] . ".html"; if ($page["menu"] == "true") {
$dir = "../public/" . $page["path"]; $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); $html = $this->twig->render($template, $pageOptions);

View file

@ -181,7 +181,11 @@ class Sorting
$limit = 4; $limit = 4;
$pages = (new Book())->getContents(); $pages = (new Book())->getContents();
foreach ($pages as $item) { foreach ($pages as $item) {
if (!$item["deleted"] && $item["published"]) { if (
!$item["deleted"] &&
$item["published"] &&
$item["menu"] != "true"
) {
if (count($recent) < $limit) { if (count($recent) < $limit) {
array_push($recent, [ array_push($recent, [
"path" => $item["path"], "path" => $item["path"],

View file

@ -36,12 +36,12 @@
{% for link in menu %} {% for link in menu %}
{% if dynamicRender is defined %} {% if dynamicRender is defined %}
{% if dynamicRender == 'true' %} {% 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 %} {% 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 %} {% endif %}
{% else %} {% 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 %} {% endif %}
{% endfor %} {% endfor %}