Handle missing guide

This commit is contained in:
Yarmo Mackenbach 2020-07-01 15:49:39 +02:00
parent 83045e10d5
commit ed410c6281

View file

@ -123,6 +123,7 @@ if(is_array($match) && is_callable($match['target'])) {
case 'guideId':
$id = htmlspecialchars($match['params']['id']);
if (file_exists("pages/guides/$id.title.html")) {
$content = file_get_contents("pages/template.html");
$guideTitle = file_get_contents("pages/guides/$id.title.html");
$guideContent = file_get_contents("pages/guides/$id.content.html");
@ -131,6 +132,15 @@ if(is_array($match) && is_callable($match['target'])) {
$content = str_replace('%CONTENT%', $guideContent, $content);
header('Content-Type: text/html; charset=utf-8');
echo($content);
} else {
$content = file_get_contents("pages/template.html");
$pageTitle = "Guide not found";
$pageContent = "<p>404 - This guide could not be found :(</p>";
$content = str_replace('%TITLE%', $pageTitle, $content);
$content = str_replace('%CONTENT%', $pageContent, $content);
header('Content-Type: text/html; charset=utf-8');
echo($content);
}
break;
case 'util':
@ -146,7 +156,7 @@ if(is_array($match) && is_callable($match['target'])) {
// No route was matched
$content = file_get_contents("pages/template.html");
$pageTitle = "404";
$pageContent = "404 - This page could not be found :(";
$pageContent = "<p>404 - This page could not be found :(</p>";
$content = str_replace('%TITLE%', $pageTitle, $content);
$content = str_replace('%CONTENT%', $pageContent, $content);
header('Content-Type: text/html; charset=utf-8');