diff --git a/template/_footer.php b/template/_footer.php index 17ffe3b..3bcc763 100644 --- a/template/_footer.php +++ b/template/_footer.php @@ -1,5 +1,4 @@ 1)) { - $templateUrlPrefix = htmlspecialchars($templateUrlPrefix . DIRECTORY_SEPARATOR); -} - if ($templateParameters["render"] === FALSE) { return; } diff --git a/template/templateParameters.php b/template/templateParameters.php index 676f826..581cf4c 100644 --- a/template/templateParameters.php +++ b/template/templateParameters.php @@ -1,4 +1,6 @@ "Document", // Set page title @@ -9,3 +11,12 @@ $defaultTemplateParameters = [ 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); + } +} \ No newline at end of file