<?php
if(!isset($_SESSION)) session_start();

// 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);
    }
}