The file header.php is loaded before of all the pages. It should contain some common information.
Usually it contains the "head" tag of the page with all indications to load the css, the meta tags, and
the menu in the top of all pages of the website.
Accessible data: all data available for the page
A basic index.php starts with:
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>Easy Magazine</title>
<link rel="stylesheet" href="<?= URIMaker::templatePath('style.css') ?>" type="text/css" media="screen" />
<meta name="keywords" content="<?= $this->metakeywords; ?>" />
<meta name="description" content="<?= $this->metadescritpion; ?>" />
</head>
Here you can see the usual html tags with some small php code.
In $this->metakeywords and $this->metadescritpion there are the keywords and the description put in
the administration for the page. Easy Magazine handle this data to manage it so all you need is just
to display it.
The templatePath() is a static method in the class URIMaker, it points to the folder containing the
template courrently in use and solve the problem of path creation in order to link the files.
<body>
<ul id="nav">
<li class="page_item"><a href="<?= URIMaker::index() ?>">Home</a></li>
<li class="page_item"><a href="<?= URIMaker::people() ?>">People</a></li>
<?
foreach ($this->pages as $page) {
echo '<li class="page_item"><a href="'.URIMaker::page($page).'">'.$page->getTitle().'</a></li>';
}
?>
</ul>
<h1><a href="<?= URIMaker::index() ?>">Title of the Magazine</a></h1>
In this script we used the people() static method from the URIMaker class, and the page() static method.
They just create the right URI for the website, so all links are well done.
We also create a menu with the home link, the link to people page and a little script that put in the
menu all the pages of the website. Pages are generated from the CMS, for each page the array
$this->pages contains a list of all pages in the DB ordered in the same way then they are ordered
in administration.