aboutsummaryrefslogtreecommitdiff
path: root/_classes/Template.php
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2023-05-22 15:18:52 -0500
committerChristian Cleberg <hello@cleberg.net>2023-05-22 15:18:52 -0500
commitdeb20fdfca35c64066fe4e375099350dc77ea408 (patch)
tree8be0f7541652e4e8f89fc4dd603fae7accf4ee24 /_classes/Template.php
downloadphp-blog-deb20fdfca35c64066fe4e375099350dc77ea408.tar.gz
php-blog-deb20fdfca35c64066fe4e375099350dc77ea408.tar.bz2
php-blog-deb20fdfca35c64066fe4e375099350dc77ea408.zip
initial commit
Diffstat (limited to '_classes/Template.php')
-rw-r--r--_classes/Template.php35
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