This repository has been archived on 2023-01-08. You can view files and clone it, but cannot push or open issues or pull requests.
stafett-for-livet/app/template.php

21 lines
971 B
PHP
Raw Normal View History

2021-09-11 18:12:29 +00:00
<?php
// Default parameter values if none is defined
$defaultTemplateParameters = [
"title" => "Document", // Set page title
"render" => TRUE, // Whether or not to render the template
];
// Initialize default parameter values
foreach(array_keys($defaultTemplateParameters) as $key) {
if (!isset($templateParameters[$key])) $templateParameters[$key] = $defaultTemplateParameters[$key];
}
// When including a template from other directories, using relative url paths is not sufficient. Therefore we use a prefix to ensure that the correct url path is given.
// Typically we put this before any local urls, such as navigation, icons etc to ensure that they use the correct path.
if (empty($templateUrlPrefix)) {
$templateUrlPrefix = dirname(str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', realpath(__DIR__)));
if ((strlen($templateUrlPrefix) > 1)) {
$templateUrlPrefix = htmlspecialchars($templateUrlPrefix . DIRECTORY_SEPARATOR);
}
2021-10-09 20:01:18 +00:00
}