by wvenable · 2y ago · 0 comments
The code for a single page looks like this:
<?php
$this->title = "Blog Article Title";
$this->shortTitle = "Title";
$this->date = mktime(0,0,0,1,27,2024);
if ($this->mode == PageMode::Meta) return;
?>
<p>Raw HTML content here<p>
There is a router that automatically adds the site header and footer, and I can add a "_layout.php" file to a folder to add another level of layout for child pages. For blog list page, it just scans all the individual article files in the folder to create the index. That where that $this->mode == PageMode::Meta comes in -- it executes the code in each file (to get the meta data) and then exits before rendering the rest. It's not going to scale to a lot of content but I'll adjust if it becomes an issue.The entire PHP code for my "framework" is only 4 PHP files (init.php, functions.php, Layout.php, and Page.php).
The advantage of being a developer is that you can use code instead of configuration or data. And you can use code to write content more efficiently.
The result (still quite incomplete) is this: https://www.codaris.com/