|
|
|
|
![]() ![]() |
Aug 3 2005, 10:28 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 309 Joined: 8-March 05 Member No.: 4,273 |
This code means every time you make a page you don't need to copy and paste the HTML code for your template, this can make editing links, especially those that appear on every page, and pages a lot easier.
1. Make sure that your template is coded so it is fully expandable. 2. Insert this code into the content area of your template, and save the file as index.php, instead of .html QUOTE <? $val = $_GET['id']; // Replace id with whatever you want to use, eg ?id=page $val .= ".html"; // Makes the filename complete so if you called ?id=index, it would be index.php it has to look for $dirty = array(".."); $clean = array(""); $val = str_replace($dirty, $clean, $val); // Prevent people from viewing root files like your password if (isset($_GET['id'])) { // Replace id with whatever you want to use, eg ?id=page if (file_exists($val)) { // This checks if the file you are trying to call exists include "$val"; } else { include "404.php"; // If the file doesnt exists it calls your 404 error page } } else { include "home.html"; // If ?id= is not set it will now go to your news page } ?> You will also need a file called home.html, that should contain what you want displayed on your home page. 3. Whenever you make a new page you just need to write the content you want included on the page, you won't need the template at all. So to make a news page you make a file called news.html write the content you want in it, and the link to get to it would be "index.php?id=news" The main advantage of this script is for when you have links, affiliates, etc displayed on your website that appear on every page and they might need to be changed, so this will make it far faster than having to go through every page to do this. For your links you would make a new page called links.html and write all your links in it. Then you would put QUOTE <? include("links.html") ?> where ever you want your links to go. Then when you want to edit the links you only need to edit one page instead of numerous other ones. I hope you find my tutorial useful. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 4th July 2008 - 08:50 PM |