Head/header.php Include

Dynamic titles, descriptions, and CSS to go in the <head> section. The $description can be whatever you’d like to name it, just as along as it doesn’t conflict with any other function.

<title><?php echo $title; ?></title>
<meta name="description" content="<?php echo $description; ?>" />
<style type="text/css"><?php echo $css; ?></style>

Index/page template

Each page must start with the following. This allows you to create a different title, description and other unique content for each page. Notice the header.php is called last.

<?php
$title = 'Title of the page';
$description = 'whats the page about';
$css = ' /* no styles yet */';
@ require_once ("header.php"); ?>

To include something once, use this code:

<?php @ require ("file.php"); ?>

To include the same file multiple times:

<?php include ("file.php"); ?>

Current Page Link Highlighting

Put the following PHP code right after the <body> tag.

This only needs to be placed here once:

<?php
$path = $_SERVER['PHP_SELF'];
$page = basename($path);
$page = basename($path, '.php');
$dir = substr(strrchr(getcwd(), '/'), 1);

$query = $_SERVER['QUERY_STRING'];
$query = explode('=', $query);
$query = $query[1];
?>

For links to be highlighted by PAGE, put the following PHP code within the link’s anchor tag. Notice the $page and the CSS class it will print. The class can be whatever you want. The $page can be changed to $dir if you want to highlight a directory.

<a <?php if($page == 'about') print ' class="current"'; ?> href="#">Link Text</a>

For multiple links that need to be highlighted do the following.

You can also include directories and pages together.

<?php if(($page == about) || ($page == services)) print ' class="current"'; ?>

The second template include method

To add content inside an already existing page, add the following. Note: this method doesn’t allow for dynamic titles, meta, or CSS. The first part of it signifies what kind of page it will include. In this case htm. The second part signifies the default content. In this case: file.php.

<?php if (isset($_GET['pg'])) {include ''.$_GET['pg'].'.htm';}
else {include 'file.php';} ?>

To change the content within the template, your links will have to be followed by ?pg=pagename. The pagename is the name of the file without the extension. Note: file names can’t contain dashes or spaces only underscores:

<a href="templatename.php?pg=pagename">Link Text</a>