NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page PHP template script

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
6 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 09-04-2005, 09:55 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
Join Date: Apr 2004
Location: IL
Posts: 348
TwiztedFake is on a distinguished road
 



PHP template script


I come up with this after getting really tired of updating multiple files when ever I wanted to make a site wide layout change. It does require use of PHP, which means your pages have to be .php instead of .htm, .html

Its is a bit of code that allows you to create one layout file and load all of your content into that layout.

Code:
<?php
$config["path"] = "LOCATION OF YOUR CONTENT TO LOAD";
$config["ext"] = EXTENSION OF THE CONTENT FILES EX. .php, .htm, .txt";

if (!isset($_REQUEST["page"])){
    $page = "main";
} else {
    $page = $_REQUEST["page"];
    $page = urldecode($page);
    $page = trim($page);
    $page = strip_tags($page);
    if (substr_count($page,"..") > 0 || substr_count($page,"~") > 0){
        $page = "main";
    }
}
$full = $config["path"] . $page . $config["ext"];
if (!is_file($full) || is_dir($full) || !file_exists($full)){
    die ("Sorry, the page you are looking for is gone. Please email the webmaster with the URL currently in your address bar so that it can be corrected. Thanks!");
} else {
    require_once($full);
}
?>
To use this simply design your layout and place this where you want you content to load. Create your content files.
????: NamePros.com http://www.namepros.com/code/120978-php-template-script.html
Now your links will look like this:
Code:
<a href="index.php?page=filename>Content</a>
Instead of having to search through all the lines of code to update content you can keep the content and layout seperate. Just a note with how I posted the code a file called 'main' will load when the page is opened for the first time. You can chage this by editing the line $page = "main"; to reflect the filename you would like to load when first accessed.
__________________
-TwiztedFake-
RTard Tutorials
Digital-Dummy to Total-Techie
TwiztedFake is offline  
Old 10-08-2005, 03:59 AM   #2 (permalink)
NamePros Regular
 
SB_GEMINI's Avatar
Join Date: Mar 2005
Location: Newport, UK
Posts: 930
SB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to beholdSB_GEMINI is a splendid one to behold
 



its not working for me, this is what ive got

Code:
<?php
$config["path"] = "http://barkus.f2s.com/sbnew";
$config["ext"] = ".php";

if (!isset($_REQUEST["page"])){
    $page = "main";
} else {
    $page = $_REQUEST["page"];
    $page = urldecode($page);
    $page = trim($page);
    $page = strip_tags($page);
    if (substr_count($page,"..") > 0 || substr_count($page,"~") > 0){
        $page = "main";
    }
}
$full = $config["path"] . $page . $config["ext"];
if (!is_file($full) || is_dir($full) || !file_exists($full)){
    die ("Sorry, the page you are looking for is gone. Please email the webmaster with the URL currently in your address bar so that it can be corrected. Thanks!");
} else {
    require_once($full);
}
?>
i added a file called main.php which is the content that i want to show up on the first page of the site (index.php)
SB_GEMINI is offline  
Old 10-19-2005, 11:06 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
Join Date: Apr 2004
Location: IL
Posts: 348
TwiztedFake is on a distinguished road
 



On this line: $config["path"] = "http://barkus.f2s.com/sbnew";

You need to add a / after sbnew and that should fix the problem.
__________________
-TwiztedFake-
RTard Tutorials
Digital-Dummy to Total-Techie
TwiztedFake is offline  
Old 10-20-2005, 12:06 AM   #4 (permalink)
NamePros Regular
Join Date: Oct 2005
Location: Midlands, England
Posts: 343
.:Mammoth261:. will become famous soon enough.:Mammoth261:. will become famous soon enough
 



Might be useful but i did it a much, well easier way?

I just included my header(layout), content, then footer. I might try this one in the future. Nice script
.:Mammoth261:. is offline  
Old 10-21-2005, 10:07 PM THREAD STARTER               #5 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
Join Date: Apr 2004
Location: IL
Posts: 348
TwiztedFake is on a distinguished road
 



Originally Posted by .:Mammoth261:.
Might be useful but i did it a much, well easier way?
????: NamePros.com http://www.namepros.com/showthread.php?t=120978

I just included my header(layout), content, then footer. I might try this one in the future. Nice script
Yes that works too but then you have multiple files to edit when making a layout change. With this your layout is one page which loads the content when called upon. All content is stored in seperate files (simple text and formating tags ex: h1, h2, p, table, etc.) away from the layout.
__________________
-TwiztedFake-
RTard Tutorials
Digital-Dummy to Total-Techie
TwiztedFake is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM
Ultimate templates Domain 48 hr. Auction SlashRoot.Com Domains For Sale - Auctions 15 09-01-2003 04:48 PM
Unlimited Templates $1 Auction, No Reserve SlashRoot.Com Domains For Sale - Auctions 10 08-23-2003 02:14 PM

 
All times are GMT -7. The time now is 02:13 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger