diff options
Diffstat (limited to '_classes/Template.php')
-rw-r--r-- | _classes/Template.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/_classes/Template.php b/_classes/Template.php new file mode 100644 index 0000000..312e566 --- /dev/null +++ b/_classes/Template.php @@ -0,0 +1,35 @@ +<?php + + +class Template +{ + public function __construct(string $canonicalURL, string $pageDescription, string $pageTitle, string $pageExtras, string $contentCol, string $commentSection) + { + $this->canonicalURL = $canonicalURL; + $this->description = $pageDescription; + $this->title = $pageTitle; + $this->extras = $pageExtras; + $this->content = $contentCol; + $this->comments = $commentSection; + $this->currentYear = date("Y"); + } + + public function echoTemplate() + { + // Get the template file + $templateFile = '_templates/template.html'; + $page = file_get_contents($templateFile); + + // Replace the template variables + $page = str_replace('{Page_Title}', $this->title, $page); + $page = str_replace('{Page_Description}', $this->description, $page); + $page = str_replace('{Canonical_URL}', $this->canonicalURL, $page); + $page = str_replace('{Page_Extras}', $this->extras, $page); + $page = str_replace('{Content_Column}', $this->content, $page); + $page = str_replace('{User_Comments}', $this->comments, $page); + $page = str_replace('{Current_Year}', $this->currentYear, $page); + + // Echo the filled-out template + echo $page; + } +}
\ No newline at end of file |