This is a simple web templating system in PHP. I originally created it for a few web sites that I administer, including the Computer Science Graduate Council at Virginia Tech. It is now in use at Uma Murthy's home page and at the Scholars of the Future program. Because of interest in this template system from others, here it is!
|
Free for non-commercial use with attribution. |
![]() |
<?php phpinfo(); ?>
http://localhost/phpinfo.phpconfig.php in a text editor, and edit the $root variable in it to point to the virtual path of the directory. This is what you would type in a browser after the http://localhost to get to the web directory. Remember not to include a trailing slash in it.
<?php
$title = "Your New Page";
require_once("theme/template.header.php");
?>
<h1>
<Your Content Goes Here>
<?php
require_once("theme/template.footer.php");
?>
require_once() statements. It can accept relative paths, so you might end up with a statement like:
require_once("../../theme/template.footer.php");
for a page in a directory that is two-levels deep. (I.e., within http://localhost/YourNewWebsite/dir/subdir/page.php).
Make sure you set the $title variable, because that's what will appear in the <title> part of the page. This also helps search engines index your page better.
To create menu items on the left side of the page, add links to navigation.php. There are two CSS classes available, Menu and SubMenu. This lets you create two-level menu structures. (And anything more than two is too much anyway, from a usability point of view!)
To customize the colors, you can edit the theme. Theme-related files are available in the /theme subdirectory. To keep it simple, themes cannot be edited or set via a web interface, and only one theme is supported at one time. To use another theme, you must replace the template.header.php, template.footer.php and base.css files.
If you simply want to change the colors instead of the entire theme, just edit base.css and set the colors you'd like to use.
Logos are available in the /images subdirectory, along with the original Photoshop files used to create them. To edit them, open the .psd files in Photoshop, and edit them as you see fit. When you're done, save the .psd, and also Save As a png file. The web browser will not use the .psd file, so if you do not export and overwrite the existing .png file, you will continue to set the original logo.
If you have permissions to alter the .htaccess configuration, and/or if you are able to alter the Apache configuration via httpd.conf, you can enter the following line in either of them:
Options +MultiViewsThis will allow you to link to PHP files without including the
.php extension in URLs. So your pages would be accessed as http://localhost/YourNewWebsite/your-page instead of http://localhost/YourNewWebsite/your-page.php. This is a good thing since it makes your URLs independent of the specific technology you're using.
If you need assistance deploying this, please send me an email.