_
_ Handy PHP
_
_
Tutorials, Scripts, Information And Other Resources arrow PHP Tutorials arrow Creating Your First Template Driven PHP Website Part 1
Wednesday, 07 January 2009
_

Refer A Friend using Revolution Money Exchange
Resource Menu
Handy PHP Store
Free Domain Name
PHP Functions
PHP Downloads
PHP Newsfeeds
PHP Tutorials
Webmaster Tools
User Login
TalkPHP
Get friendly help with your PHP problems for free.
www.talkphp.com
The PHP Resource Index
 
Handy PHP
Free PHP Help!

Creating Your First Template Driven PHP Website Part 1 Print E-mail
Written by Handy PHP Administrator   
Monday, 23 April 2007

     Using this system with a few modifications, you can create a static website with templates. Basically, you would create a file for each of the modules and a seperate file for each content page like so:

main_menu.php Sample 2

CODE: main_menu.php
<?php
$main_menu .= "<a href=\"http://www.handyphp.com\" title=\"Handy PHP - Free PHP Resources and Help\">Handy PHP</a><br />";
$main_menu .= "<a href=\"http://www.google.com\" title=\"Google - Internet Search Engine\">Google</a><br />";
$main_menu .= "<a href=\"http://www.joomla.org\" title=\"Joomla! - Open Source Content Management System\">Joomla!</a><br />";
$main_menu .= "<a href=\"http://www.vwone.com\" title=\"VW One - Volkswagen Information Website\">VW One</a><br />";
$main_menu .= "<a href=\"http://www.forum500.com\" title=\"Forum500 - A General Information Website\">Forum500</a><br />";
?>

 

header.php Sample 2

CODE: header.php
<?php
$header .= $page_title;
$header .= "<br />Probably Some Type Of Advertisement Here!<br />";
?>

 

footer.php Sample 2

CODE: footer.php
<?php
$footer .= "© 2007 My Website";
?>

 

index.php Sample 2

CODE: index.php
<?php

$site_title = "My Website";
$page_title = "Sample Template Page 2";
$main .= "<div style=\"text-align:left; margin:10px;\">Welcome to my second template based website!<br />I hope that you enjoy learning PHP in this manner. I have found that I learn best if I can see the code and the output together. Many times you can't see the output until you sit down and write the script just to find out that you don't like what the script does!</div>";

require('header.php');
require('main_menu.php');
require('footer.php');
require('template.php');

?>

These files would output the following: template_sample2_1.jpg

The output is basically the same but now the only difference in the handler file is the title and content which means that you can create as many handler files as you wish. Basically, your website will be it's normal static content but your template, header, footer, and menu can all be edited quickly and easily. If you use this same method for every page on your website, then you can change thelayout for the entire website be only editing the one template file! Or if you need to add a menu item, you can make that change for the entire website by editing the menu file. This makes creating and maintaining your website much easier.

 

 

 



Last Updated ( Sunday, 18 May 2008 )
 
< Prev   Next >

_
 
_
_
© 2009 Handy PHP