joshg678
10-23-2003, 09:30 PM
Well as the title says i think you know what im talking about.
I started a script that would allow me to use one template (layout) and have a bunch of pages useing the same layout. But when I made the script it did not work right, so I turned to james (my friend), he fixed it up for me and it works just the way I wanted it to. (and some help from here)
First create a folder called my_pages, then put a default.php, that will show when nothing i specified, make page_not_found.php, that will display when the file can not be fond.
<?
$content_folder = "my_pages/";
if(!isset($_GET['page']) || $_GET['page'] == ""){
$inc_ref = "default";
}
else{
$inc_ref = $_GET['page'];
}
if(!file_exists($content_folder.$inc_ref.".php")){
$inc_ref = "page_not_found";
}
include($content_folder.$inc_ref.".php");
?>
for this to work all pages in the folder "my_pages" have to be the .php extension, and to get to the page you want, lets say its wee.php. To get to it, the link would be domain.com/index.php?page=wee
If you want the title to change just put the <title> tags in the page that you include.
Also here is one that works with images.
<?
print "<html>\n";
print "<body>\n";
$i = $_GET['img'];
if(!isset($i)){
print "No Image Specified";
}
else{
if(file_exists($i)){
print "<img src=\"$i\" border=\"0\">\n";
}
else{
print "Image does not exist";
}
}
print "</body>\n";
print "</html>\n";
?>
I don't have an example of this one yet, but i'll have one soon.
I started a script that would allow me to use one template (layout) and have a bunch of pages useing the same layout. But when I made the script it did not work right, so I turned to james (my friend), he fixed it up for me and it works just the way I wanted it to. (and some help from here)
First create a folder called my_pages, then put a default.php, that will show when nothing i specified, make page_not_found.php, that will display when the file can not be fond.
<?
$content_folder = "my_pages/";
if(!isset($_GET['page']) || $_GET['page'] == ""){
$inc_ref = "default";
}
else{
$inc_ref = $_GET['page'];
}
if(!file_exists($content_folder.$inc_ref.".php")){
$inc_ref = "page_not_found";
}
include($content_folder.$inc_ref.".php");
?>
for this to work all pages in the folder "my_pages" have to be the .php extension, and to get to the page you want, lets say its wee.php. To get to it, the link would be domain.com/index.php?page=wee
If you want the title to change just put the <title> tags in the page that you include.
Also here is one that works with images.
<?
print "<html>\n";
print "<body>\n";
$i = $_GET['img'];
if(!isset($i)){
print "No Image Specified";
}
else{
if(file_exists($i)){
print "<img src=\"$i\" border=\"0\">\n";
}
else{
print "Image does not exist";
}
}
print "</body>\n";
print "</html>\n";
?>
I don't have an example of this one yet, but i'll have one soon.