Quote:
Originally Posted by Arcanum
Okay but what about coding a .php file to handle more than 1 template?
|
In order to use a single php file for multiple templates, you would use url variations using $_GET.
If your main page was
information.php you would have to write multiple request methods such as:
information.php?do=main
information.php?do=contact
information.php?do=about
You would create your templates and put them all into the $globaltemplates array() like
$globaltemplates = array(
'main',
'contact',
'about'
);
When working with multiple templates, I do advise to use some prefix such as
info_ or something.
Then you setup your php file to handle the requests.
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'yourscript');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array(
'main',
'contact',
'about'
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// Begin your templates
// Main template and code
if ($_REQUEST['do'] == 'main')
{
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('main') . '");');
}
// Contact template and code
if ($_REQUEST['do'] == 'contact')
{
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('contact') . '");');
}
// About template and code
if ($_REQUEST['do'] == 'about')
{
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('about') . '");');
}
?>
Its a bit complex and hard for me to explain in a spur of the moment forum post,
but basically, you have to handle the code for your different url requests, then
write the different
eval() to fetch the templates within those requests.
I suggest looking into the code of a product that uses multiple urls to get a better understanding.
******************************
Quote:
Originally Posted by Never2Day
I have no idea how to do this sorry I have managed to do the first part but the second code i have no idea what to do with where to put it or what i should do cause when i did put it onto a blank page i got errors.
|
Your created template may contain anything you wish, even if its a simple <b>Welcome</b>
But, if you want it to be contained within your forum layout, there are several variables you must call such as $headinclude,$header,$navbar and $footer
This places your content within the vbulletin page.
Simply by pasting the code provided into a new template should work for you.
As far as the PHP file, there are really only two areas you need to edit.
These areas MUST conform to the template name you just created.
Code:
// pre-cache templates used by all actions
$globaltemplates = array(
'TEMPLATENAME'
);
and
Code:
eval('print_output("' . fetch_template('TEMPLATENAME') . '");');
Lets say you create a template named
aboutme
You would edit the supplied php code in this thread to:
Code:
$globaltemplates = array(
'aboutme'
);
and
Code:
eval('print_output("' . fetch_template('aboutme') . '");');
within the php file.
Save the file as
aboutme.php and upload to your forum root so when people
visit
www.yoursite.com/forum/aboutme.php
it will display the contents of the template you created.
If you need assistance with a simple page, contact me.
I'd like to add that sometimes the forumjump menu does not work on pages
in which case you need to add
PHP Code:
construct_forum_jump();
above eval('$navbar = "' . fetch_template('navbar') . '";');
Also, if you would like to have the name appear in the navbar when viewing the page,use
PHP Code:
$navbits = construct_navbits(array('' => 'YOUR PAGE NAME HERE'));
above eval('$navbar = "' . fetch_template('navbar') . '";');