Some basics of vB3(mini howto)
also some basic php junk
the most important thing if you want to make pages based on templates or anything of the such would be to first know how to "
connect" to vbulletin, and then learn how to call and eval templates. so lets take a look at the most BASIC page we can do
PHP Code:
<?php // ## Changes Directory so it can accesss vBulletin IF we are outside the forums folder, if not this is not nessary ## chdir("./forums");
// ## Error Reporting ( we use error reporting in php so we can control the display of error messages // ## we will use this because all vBulletin files follow the same error reporting rules) ## error_reporting(E_ALL & ~E_NOTICE);
// ## this action here cache's the templates so that everytime their needed a querry wont be needed to run // ## the names in there are just the template names :), there must be a comma after everyone but the last ## $globaltemplates = array( 'main' );
// ## Grabs global.php this grabs vbulletins global.php so we can use the most basic of vBulletins functions ## require_once("./global.php");
// ## this calls to print out one main template ## eval('print_output("' . fetch_template('main') . '");'); ?>
So theres a basic file, if your going to make one, that would i think be the mininum needed. now if you are going to be making
somthing abit more advanced. suchas calling more than one template, or doing an action it becomes abit more complicated
PHP Code:
<?php // ## Changes Directory so it can accesss vBulletin IF we are outside the forums folder, if not this is not nessary ## chdir("./forums");
// ## Error Reporting ( we use error reporting in php so we can control the display of error messages // ## we will use this because all vBulletin files follow the same error reporting rules) ## error_reporting(E_ALL & ~E_NOTICE);
// ## this here defines the "this_script" function, which if you use template conditionals, it will come in handy :) ## define('THIS_SCRIPT', 'page');
// ## this action here cache's the templates so that everytime their needed a querry wont be needed to run // ## the names in there are just the template names :), there must be a comma after everyone but the last ## $globaltemplates = array( 'main', 'big', 'small' );
// ## Grabs global.php this grabs vbulletins global.php so we can use the most basic of vBulletins functions ## require_once("./global.php");
// ## ok this next set of lines "eval"'s our templates so they can be called inside the template we will print out ## eval('$big = "' . fetch_template('big') . '";'); eval('$small = "' . fetch_template('small') . '";');
// ## this calls to print out one main template ## eval('print_output("' . fetch_template('main') . '");'); ?>
PHP Code:
// ## if were going to use actions and their templates // ## arnt used anywhere else in the file but the actions we add this // ## under $globaltemplates = array(); // ## where small is would be the action name // ## and other is the template used ## $actiontemplates = array( 'small' => array( 'other' ) ); // ## this is a action, and it can be added before the final // ## eval('print_output("' . fetch_template('main') . '");'); // ## anything done before this request can be called inside the template // ## so lets say if you evalled the template big, as $bit, it can be called // ## here with other. ## if ($_REQUEST['do'] == 'small') { eval('print_output("' . fetch_template('other') . '");'); }
one more note
if your going to write a script that is ALL actions you should add somthing like this right after the call to gobal.php
PHP Code:
if (empty($_REQUEST['do'])) { $_REQUEST['do'] == 'small'; }
this will ensure that if the usergoes to foo.php instead of foo.php?do=small they will still see the correct page
Mini Tut by Faranth
(with some help from Brad.loo fixing my silly newbie mistakes )
Thanks Faranth! I read the whole thread and now I understand a little more how the whole thing is working
The "actions", are they all included in one php file? But I guess not, they must be spread evywhere. To list all these actions, is the way to do that to Ctrl-F through all the files and search for "do=" ???
And also, where are all the functions, do we simply need to require global.php for all the functions beeing available?
Hi Zachery,
I tested the first & second examples but I keep getting the following lines in my browser:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD><BODY></BODY></HTML>
I went and changed couple of things and came up with this version:
PHP Code:
<?php
// ## Changes Directory so it can accesss vBulletin IF we are outside the forums folder, if not this is not nessary ##
chdir("./vb3");
// ## Error Reporting ( we use error reporting in php so we can control the display of error messages
// ## we will use this because all vBulletin files follow the same error reporting rules) ##
error_reporting(E_ALL & ~E_NOTICE);
// ## this here defines the "this_script" function, which if you use template conditionals, it will come in handy :) ##
define('THIS_SCRIPT', 'page');
// ## this action here cache's the templates so that everytime their needed a querry wont be needed to run
// ## the names in there are just the template names :), there must be a comma after everyone but the last ##
$globaltemplates = array(
'header',
'navbar',
'footer'
);
// ## Grabs global.php this grabs vbulletins global.php so we can use the most basic of vBulletins functions ##
require_once("./global.php");
// ## ok this next set of lines "eval"'s our templates so they can be called inside the template we will print out ##
eval('$header = "' . fetch_template('header') . '";');
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('$footer = "' . fetch_template('footer') . '";');
Seems so, so there is no way to add footer/header templates to hard coded page then?
Has anyone figured out if it's possible?
I have a lot of content outside of my forums which I'd love to be able to include the header and footer from the template on! This way I could update the style of my whole site, forums and static content, through the admincp.
I've tried almost everything I can think of, if someone has a simple test page they can show me I'd be really, really greatful
how can a do one code for ?do= and thene whene i make a new template i can do ?do=test and so that i can do it at's mutch as i want. please help my. :d