UK Webmaster Talk - Online Marketing - SEO


 

Prevent copying your template every time you make a new page

This is a discussion on Prevent copying your template every time you make a new page within the Programming Articles forums, part of the Webmaster Articles/Tutorials category; This code means every time you make a page you don't need to copy and paste the HTML code for ...


Go Back   UK Webmaster Talk - Online Marketing - SEO > Webmaster Articles > Webmaster Articles/Tutorials > Programming Articles

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices

Reply

 

LinkBack Thread Tools Display Modes
Old 03-08-2005, 11:24   #1 (permalink)
Senior Member
 
Join Date: Apr 2005
Posts: 350
iTrader: 0 / 0%
rustypaulin has a spectacular aura about
Send a message via AIM to rustypaulin Send a message via MSN to rustypaulin
Default Prevent copying your template every time you make a new page

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.
rustypaulin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-08-2005, 20:26   #2 (permalink)
Senior Member
 
Join Date: Jun 2005
Posts: 389
iTrader: 0 / 0%
FrozenDice will become famous soon enough
Default

Good article. This is almost like what I use on my sites, although I added a check to make sure there was no http:// so that people didn't use my site as a proxy. You might want to put that in.
FrozenDice is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
copying, make, page, prevent, template, time

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Unique Proxy Template ViLe Sales/Auctions 0 22-08-2007 20:18
Free Mambo and Joomla Template Template Skin Indigosi Graphics Forum 5 22-02-2006 17:18
iPixelDesigns Template and Domain for Sale Ic3CoLd Websites For Sale 0 18-07-2005 19:17
My first template EVER! Lewis Website Design Forum 4 21-06-2005 06:41
Free template for anyone who wants it. FrozenDice Website Design Forum 7 19-06-2005 09:34


All times are GMT +1. The time now is 19:15.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
UK Webmaster Forum © WebmasterTalk.co.uk | Design by Forbairt

Ad Management by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41