Using a template system on your webpage.

Step 1

Make all of your .html pages into .php. This includes your index.html. MOST hosts will still function the same if you change the extension. But you MUST delete or rename your index.html and replace with index.php. Check with your webhost if it does not work, they can help change the site's settings. This may take the most or least time depending on your FTP knowledge. You can simply select all the pages you want to change in most FTP services and click "rename" and change each extension fairly quickly.

Step 2

Create 3 new files: header.php, body.php, footer.php. Of course you can name them anything you like. I just like to keep things as simple as possible.

In your header file, you want to place all of your CSS (if applicable), javascript codes, meta tags and usually anything that goes between the <head></head> tags EXCEPT the <title></title> tags. There IS a way to use php to put the title tags inside the header file but as I said we're going to keep this simple. You'll need to manually include the title for each page.

In your body.php file you want to add all the HTML coding that you want to display on your template files uniformly. For example, lets say you have a "news" page. You want to include ALL the html coding ABOVE the actual news. Do not include the news content in the body.php file.

In your footer file you can either include the rest of the html code if you are "wrapping" your page around your news or you can put whatever is at the bottom of your webpage.

In the body.php file:

All the html above the news, sidebars, images, etc. <TABLE><TR><TD>

In the footer.php file:

</TD></TR></TABLE> Copyright, footer information, etc.

So this is how you use the header and footer files. Open your news.php file and put this information

Open news.php in notepad or whatever HTML editor you use

<HTML>
<HEAD> <TITLE>eFed News!</TITLE> <?PHP include 'header.php'; ?> </HEAD>
< BODY><?PHP include 'body.php'; ?>

This is where all your site's news goes and anything else you want to include on the page.

<?PHP include 'footer.php'; ?> </BODY>
</HTML>

Please note the location of each included template file. Do you see how you can now edit only one file and it will change each page in the site? All you have to do is repeat this process for each page you want to look the same.



URL for news «Using a template system on your webpage.»   -
«RoughKut.com news»   -