diff --git a/index.php b/index.php index f196d91..67203c4 100644 --- a/index.php +++ b/index.php @@ -109,10 +109,8 @@ if(is_array($match) && is_callable($match['target'])) { case 'guideId': $id = htmlspecialchars($match['params']['id']); - if (file_exists("views/guides/$id.title.php")) { - $guideTitle = file_get_contents("views/guides/$id.title.php"); - $guideContent = file_get_contents("views/guides/$id.content.php"); - echo $templates->render('guide', ['guide_title' => $guideTitle, 'guide_content' => $guideContent]); + if (file_exists("views/guides/$id.title.php") && file_exists("views/guides/$id.content.php")) { + echo $templates->render('guide', ['id' => $id]); } else { echo $templates->render("404"); } diff --git a/views/guide.php b/views/guide.php index 792791e..0c8bdfe 100644 --- a/views/guide.php +++ b/views/guide.php @@ -1,7 +1,7 @@ <?php $this->layout('template.base', ['title' => $title]) ?> -<h1><?=$this->escape($guide_title)?></h1> +<h1><?php $this->insert("guides/$id.title") ?></h1> <div class="content"> <p><a href='/guides'>Back to guides</a></p> - <?=$guide_content?> + <?php $this->insert("guides/$id.content") ?> </div>