View Full Version : PHP Page
ukliam
Thu 4th Jan '01, 10:12am
How can I create a PHP page that will use my headers and footer?
I want to create a few more pages with some other information on them, but I want these pages to use the same header and footer as my forums.
I want to be able to store this new information in templates and have them called up as well.
Could someone send me a PHP page I could use that will display my header.
Allow me to call up a template with all my html tables and stuff in it.
And display my footer.
Sorry if this is not very clear
Thanks in advance
Sean
Wayne Luke
Thu 4th Jan '01, 10:19am
I just use the vBulletin template system to hold any page that I want to use other templates. This gives the added benefit of being editable from anywhere without the use of FTP like when I am at my parent's house.
Then I create a file that will call the template. It is simple really.
Here is one for our chat page.
<?php
require("global.php");
eval("echo dovars(\"".gettemplate("chat")."\");");
?>
Just put the proper template name in the gettemplate function.
ukliam
Thu 4th Jan '01, 10:42am
simple as that hey :)
thanks, I thaught it would be a bit harder than that....
::feels stupid::
ukliam
Thu 4th Jan '01, 1:06pm
k.. next question.
Now I have my one page, how do I get it to go to different sections...
like if you go to
/map.php?action=scotland
it would take to to a template called scotland
but if you went to
/map.php?action=england
it would take to to a template called england
Thanks in advance
Sean
bmurray
Thu 4th Jan '01, 1:20pm
Just do something along these lines. For each action, have an if statement that will execute the appropriate code.
<?php
if ($action == "scotland") {
// Code used if action=scotland
// Use Template Scotland
eval("echo dovars(\"".gettemplate("scotland")."\");");
}
if ($action == "england") {
// Code used if action=england
// Use Template England
eval("echo dovars(\"".gettemplate("england")."\");");
}
?>
Also, after getting that to work, you may want add more to it to return an error if an invalid action is set, or set a default action to take if none is given at all.
Mike Sullivan
Thu 4th Jan '01, 1:27pm
Here, this'll be easier to maintain:
<?php
// Add any templates to the array (in the same format) that you want to allow
$allowed = array(
"england" => "yes",
"scotland" => "yes"
);
if ( !isset($allowed["$action"]) ) {
echo "Invalid action specified";
}
eval("echo dovars(\"".gettemplate("$action")."\");");
?>
ukliam
Thu 4th Jan '01, 2:00pm
Ed, the trouble is I won't actually be using the same names for the templates.
Ben that kinda works..... but how do I set it to load a template when no action is set.
ie when they just go to /map.php
JohnM
Thu 4th Jan '01, 2:17pm
Just use ed's code and change the names.
Mike Sullivan
Thu 4th Jan '01, 5:31pm
Just change the array part:
"england" => "yes",
// In the format:
// "template name" => "yes"
// Remember the comma if it's not the last part
And if an invalid action is set, in mine just the echo "Invalid..."; line to:
$action = "default template name";
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights