Implement new template parameter

This commit is contained in:
Willy 2021-09-06 09:04:29 +02:00
parent 7f930ff544
commit 780df09b70
4 changed files with 23 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// This file should serve as an example showing all the current implemented features. // This file should serve as an example showing all the current implemented features.
// Parameters that will be used in the template file // Parameters that will be used in the template file
$templateParameters["render"] = true; // Whether or not to render the template
$templateParameters["title"] = "Eksempel side"; // Sets the page title $templateParameters["title"] = "Eksempel side"; // Sets the page title
// Include the top of page // Include the top of page

13
login.php Normal file
View File

@ -0,0 +1,13 @@
<?php
// Parameters that will be used in the template file
$templateParameters["title"] = "Logg inn"; // Sets the page title
// Include the top of page
include_once("template/_header.php");
?>
<h1>Logg inn</h1>
<p>Her kan du logge inn</p>
<?php
// Include the rest of the page
include_once("template/_footer.php");
?>

View File

@ -1,3 +1,8 @@
<?php
if ($templateParameters["render"] === false) {
return;
}
?>
</main> </main>
</div> </div>
</div> </div>

View File

@ -7,6 +7,9 @@ if ((strlen($templateUrlPrefix) > 1)) {
$templateUrlPrefix = $templateUrlPrefix . DIRECTORY_SEPARATOR; $templateUrlPrefix = $templateUrlPrefix . DIRECTORY_SEPARATOR;
} }
if ($templateParameters["render"] === false) {
return;
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -39,6 +42,7 @@ if ((strlen($templateUrlPrefix) > 1)) {
<nav> <nav>
<ul> <ul>
<li><a href="<?=$templateUrlPrefix;?>">Forside</a></li> <li><a href="<?=$templateUrlPrefix;?>">Forside</a></li>
<li><a href="<?=$templateUrlPrefix;?>login.php">Logg inn</a></li>
<li><a href="<?=$templateUrlPrefix;?>example.php">Eksempel</a></li> <li><a href="<?=$templateUrlPrefix;?>example.php">Eksempel</a></li>
</ul> </ul>
</nav> </nav>