Merge pull request 'Switch to using Plate's 'insert' method for rendering the guid pages' (#4) from screenbeard/keyoxide:switch-sub-pages-to-insert into dev

Reviewed-on: https://codeberg.org/yarmo/keyoxide/pulls/4
This commit is contained in:
yarmo 2020-07-05 13:12:00 +02:00
commit 3dd7ba4cb4
2 changed files with 4 additions and 6 deletions

View file

@ -109,10 +109,8 @@ if(is_array($match) && is_callable($match['target'])) {
case 'guideId': case 'guideId':
$id = htmlspecialchars($match['params']['id']); $id = htmlspecialchars($match['params']['id']);
if (file_exists("views/guides/$id.title.php")) { if (file_exists("views/guides/$id.title.php") && file_exists("views/guides/$id.content.php")) {
$guideTitle = file_get_contents("views/guides/$id.title.php"); echo $templates->render('guide', ['id' => $id]);
$guideContent = file_get_contents("views/guides/$id.content.php");
echo $templates->render('guide', ['guide_title' => $guideTitle, 'guide_content' => $guideContent]);
} else { } else {
echo $templates->render("404"); echo $templates->render("404");
} }

View file

@ -1,7 +1,7 @@
<?php $this->layout('template.base', ['title' => $title]) ?> <?php $this->layout('template.base', ['title' => $title]) ?>
<h1><?=$this->escape($guide_title)?></h1> <h1><?php $this->insert("guides/$id.title") ?></h1>
<div class="content"> <div class="content">
<p><a href='/guides'>Back to guides</a></p> <p><a href='/guides'>Back to guides</a></p>
<?=$guide_content?> <?php $this->insert("guides/$id.content") ?>
</div> </div>