Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Some basics of vB3(mini howto)
Zachery's Avatar
Zachery
Join Date: Jul 2002
Posts: 11,440

 

Ontario, Canada
Show Printable Version Email this Page Subscription
Zachery Zachery is offline 01-08-2004, 10:00 PM

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 )
Reply With Quote
  #92  
Old 08-14-2004, 05:19 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by PtP
My apoligies for thinking you are a guru
I am just a simple student who is still learning things himself
Reply With Quote
  #93  
Old 09-07-2004, 02:05 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can this be done Zachery?

say I have a var called $a and i want it evald on its own so that I can use it in the templates how do i assign just a value to that and still eval? i.e value 22
Reply With Quote
  #94  
Old 10-11-2004, 02:09 PM
khaleel's Avatar
khaleel khaleel is offline
 
Join Date: Oct 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thankyou very much this is good newbs like me who have come from along time experince with phpBB and IpB :squareeyed:
Reply With Quote
  #95  
Old 10-16-2004, 06:18 PM
Seanie Seanie is offline
 
Join Date: Mar 2004
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Warning: main(): open_basedir restriction in effect. File(./global.php) is not within the allowed path(s): (/home/latch/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/latch/public_html/test.php on line 16

.... my forums are in /home/forums/public_html/

is there anyway to get it to work :S
Reply With Quote
  #96  
Old 10-22-2004, 09:00 AM
C.Birch C.Birch is offline
 
Join Date: Apr 2002
Posts: 459
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

read the error it tell's you the prob right away.

open_basedir restriction in effect. File(./global.php) is not within the allowed path

in other words the server setup does not let you pull files from other site paths this is because there might be other sites on the server you dont own and if there not any open_basedir restriction you could pull files from other peoples sites and this could let people hack people or nick personal information.
Reply With Quote
  #97  
Old 10-23-2004, 07:39 PM
Seanie Seanie is offline
 
Join Date: Mar 2004
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by C.Birch
read the error it tell's you the prob right away.

open_basedir restriction in effect. File(./global.php) is not within the allowed path

in other words the server setup does not let you pull files from other site paths this is because there might be other sites on the server you dont own and if there not any open_basedir restriction you could pull files from other peoples sites and this could let people hack people or nick personal information.
i know that now... we've fixed it
Reply With Quote
  #98  
Old 11-07-2004, 10:41 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:

$actiontemplates 
= array(
                            
'small' => array(
                                                     
'other'
                                                    
)
); 
What exactly does this do?
Reply With Quote
  #99  
Old 11-22-2004, 09:36 PM
GeZuS P GeZuS P is offline
 
Join Date: Oct 2004
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OMG Thanks, I feel like a god now !!!
Reply With Quote
  #100  
Old 01-08-2005, 12:13 AM
PaulioTheGreat PaulioTheGreat is offline
 
Join Date: Jun 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey, i suppose you lot have been asked this loads of times, i am using this code:

Code:
<?php
// ## Changes Directory so it can accesss vBulletin IF we are outside the forums folder, if not this is not nessary ##
chdir("./forum");

// ## 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(
'index.php'
);

// ## 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('index.php') . '");');
?>
And is there any way of fixing the problems with the javascripts and images WITHOUT adding the vb home code to the relative urls?

Here is the page:

http://www.justonxbox.com/test.php

Also i know the template is called index.php, this is so that when i make my site from these they are easily edited as that will be the name for this page once done etc... etc...

Thanks Paul
Reply With Quote
  #101  
Old 01-16-2005, 07:23 PM
grooveh grooveh is offline
 
Join Date: Jul 2002
Location: Canada
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, thank you!
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 06:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05230 seconds
  • Memory Usage 2,332KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (5)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete