Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

PHP template script

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

TwiztedFake

Established Member
Impact
1
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.
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.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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)
 
0
•••
On this line: $config["path"] = "http://barkus.f2s.com/sbnew";

You need to add a / after sbnew and that should fix the problem.
 
0
•••
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
 
0
•••
.:Mammoth261:. said:
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

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.
 
0
•••
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back