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
  #12  
Old 01-09-2004, 03:49 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[high]* Faranth is now confused [/high]
Reply With Quote
  #13  
Old 01-09-2004, 04:18 PM
MindTrix's Avatar
MindTrix MindTrix is offline
 
Join Date: Apr 2002
Location: United Kingdom
Posts: 1,833
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yup that was my main aim Lol, nah i meant at first that it was confusing because i was reading too fast, and still scratching up on the ol' PHP
Reply With Quote
  #14  
Old 01-09-2004, 04:19 PM
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 MindTrix
Yup that was my main aim Lol, nah i meant at first that it was confusing because i was reading too fast, and still scratching up on the ol' PHP
you worried me for a moment :P

hope it helped
Reply With Quote
  #15  
Old 01-09-2004, 04:50 PM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Faranth
you worried me for a moment :P

hope it helped
Good job faranth, looks complete and hopefully helps some noobs
Reply With Quote
  #16  
Old 01-10-2004, 02:28 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 Mr. HillBilly
Nice jobs, could you make a mini guide for making templates?
whatcha mean? templates are simple to make, its just html >.<
Reply With Quote
  #17  
Old 01-10-2004, 05:22 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I notcied one error with the action templates call. It should be:

PHP Code:
$actiontemplates = array(
                            
'small' => array(
                                                     
'other'
                                                    
)
); 
Reply With Quote
  #18  
Old 01-10-2004, 05:23 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

whatchu talkin about foo :P
Reply With Quote
  #19  
Old 01-10-2004, 06:32 AM
Mr. HillBilly Mr. HillBilly is offline
 
Join Date: Oct 2003
Posts: 101
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks much for the guide!

I made a page, first time I've ever done it.

http://ph33rnet.com/uc.php
Reply With Quote
  #20  
Old 01-11-2004, 07:49 PM
rrottman rrottman is offline
 
Join Date: Jun 2002
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Faranth, any hint:
I copied the first code block (the very easy one :-) ) and tried it: Nothing gets displayed. Any hint?
Reply With Quote
  #21  
Old 01-11-2004, 07:52 PM
rrottman rrottman is offline
 
Join Date: Jun 2002
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I created a new, empty file. This is all and exactly what's in there:

PHP Code:
<?php
    chdir
("./forum");
    
error_reporting(E_ALL & ~E_NOTICE);
    
$globaltemplates = array('main');
    require_once(
"./global.php");
    eval(
'print_output("' fetch_template('main') . '");');
?>
It's saved as index.php in the website root, while vB sits in /forum.
If I open http://www.mydomain.com in a browser, this is what I receive:

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>
Any idea?
For troubleshooting I replaced the print_output with:

echo fetch_template('main');

and received an empty string, too.

Please help.
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 01:30 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.07235 seconds
  • Memory Usage 2,333KB
  • 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_html
  • (6)bbcode_php
  • (3)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
  • (3)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