GYSN Underground
Our Sponsors:

Go Back   GYSN Underground

Notices

 
Thread Tools Display Modes
  #1  
Old 05-08-19, 01:05 PM
JohnnyBoy's Avatar
JohnnyBoy JohnnyBoy is offline
Rick Mills FTW?
 
Join Date: May 2016
Location: GYSN
Posts: 131
Thanks: 0
Thanked 1 Time in 1 Post
JohnnyBoy is on a distinguished road
Default Some basics of vB3 programming

This will be called a 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 first to know how to.

Connect to vBulletin, and then learn how to call and eval templates. So let's 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 there's a basic file, if you're going to make one, that would I think to be the minimum needed.

Now if you are going to be making something a bit more advanced.

Such as calling more than one template, or doing an action it becomes a bit 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 you're going to write a script that is ALL actions you should add something like this right after the call to the global.php script:

PHP Code:
if (empty($_REQUEST['do'])) 
{
$_REQUEST['do'] == 'small';

This will ensure that if the user goes to foo.php instead of foo.php?do=small they will still see the correct page.

No thanks no support and I mean it no support!!! - Excellent vBulletin support @ GYSN Underground.
justfuckinggoogleit.com

Bookmarks

Tags
based, basic, basics, call, connect, eval, learn, mini-howto, page, programming, templates, vb3, vbulletin

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Valid XHTML 1.0 Transitional Valid CSS!

Design by: Hoxxy & .v0id    All times are GMT +2. The time now is 02:47 AM. [ GYSN Underground ]