Switch to using Plate's 'insert' method for rendering the guid pages

This commit is contained in:
screenbeard 2020-07-05 10:51:44 +09:30
parent 16ab2f640f
commit 56853211fd
No known key found for this signature in database
GPG key ID: 3AB72AFE4AF4C7A4
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>