for the search, my way to preload images! haha

Search for in

Easy-updating

PHP Coding Tutorials | Submited Apr 15, 2008

Written by: Mr. Evil [BOFH]

How to split your site's layout into separate files so that when one is updated, the whole site will update.

Meh..


Once upon a time (yesterday), I was sick of updating over 100 pages manually for each change that I made to 7B's layout.
Then I had one of those "Why didn't I think of that before?" moments, and decided to use PHP's include() function.
So I split each section of the site into HTML files. For example, if I need to add an extra link to the navbar, I'll change nav.html, and it'll update throughout the site.

Example


In nav.html this is what I have:
<ul>
<li><a href="../linky.php">One</a></li>
<li><a href="../linky2.php">Two</a></li>
<li><a href="../linky3.php">Three</a></li>
<li><a href="../linky4.php">Four</a></li>
</ul>


And on the main page I have this:
<div id="nav">
<?php include('nav.html'); ?>
</div>


And if you use that, and view the page source, this is what you'll see:
<div id="nav">
<ul>
<li><a href="../linky.php">One</a></li>
<li><a href="../linky2.php">Two</a></li>
<li><a href="../linky3.php">Three</a></li>
<li><a href="../linky4.php">Four</a></li>
</ul>
</div>


Simple, huh?

tags Tags: auto update php include function html

1Thumbs up  Thumbs down0

Related Tutorials
Style Tags
Text editing
Tables with HTML
Fieldsets
Randomness with PHP
Filtering text
Easy-updating
Alternative to if /else statements
Creating "Your IP is" images
Using $_GET to display content
1 Comments
  Mr. Evil [BOFH] ~ 04/21/08, 2:07am
Picture..
I just noticed, if you do this your "page impressions" go up like whoa.

It's kinda like having iFrames on every page.

1 


Sorry, you have to be a member to comment tutorials