firt write up of basic page class

This commit is contained in:
Göran Heinemann 2021-05-12 15:59:11 +02:00
parent a8ecc16e02
commit 575e2b5a85
No known key found for this signature in database
GPG Key ID: D9EC7BA4C5BF1EEC

59
lib/Page.php Normal file
View File

@ -0,0 +1,59 @@
<?php
class Page
{
private $pagecontent = '';
private $title = '';
private $navigation = '';
//default boilerplate html code
private $template = '
<!DOCTYPE html>
<html lang="de">
<head>
<title>$$TITLE$$</title>
</head>
<body>
<nav>
$$NAVIGATION$$
</nav>
<div>
$$PAGECONTENT$$
</div>
</body>
</html>
';
public function __construct()
{
}
public function __destruct($title)
{
$this->title = $title;
}
public function addContent($content)
{
$this->pagecontent .= $content;
}
public function setTemplate($template){
$this->template = $template;
}
public function setNavigation($navigation){
$this->navigation = $navigation;
}
public function displayPage(){
$page = $this->template;
$page = str_replace('$$TITLE$$', $this->title, $page);
$page = str_replace('$$NAVIGATION$$', $this->navigation, $page);
$page = str_replace('$$PAGECONTENT$$', $this->pagecontent, $page);
echo $page;
}
}