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
  #52  
Old 02-03-2004, 05:18 AM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool, waiting for further instructions.
Reply With Quote
  #53  
Old 02-04-2004, 11:58 AM
mossyuk mossyuk is offline
 
Join Date: Jul 2002
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im confused - how do i make the navbar i have included in my page change to show your status as logged in?
Reply With Quote
  #54  
Old 02-11-2004, 01:35 AM
Gio Takahashi's Avatar
Gio Takahashi Gio Takahashi is offline
 
Join Date: Jul 2003
Location: Cape Coral
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mossyuk
im confused - how do i make the navbar i have included in my page change to show your status as logged in?
This is nice stuff here Faranth, very useful.

I do have a question, how do I have "Who is online" show the location.

IE:

Gio "Unknown"
main.php

To

Gio Test Page
test.php
Reply With Quote
  #55  
Old 02-11-2004, 01:48 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I THINK i know how to do that, but i need to double check somthing ^_^
Reply With Quote
  #56  
Old 02-11-2004, 10:46 AM
Dark_Wizard Dark_Wizard is offline
 
Join Date: Nov 2001
Location: North Carolina
Posts: 1,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Gio Takahashi
This is nice stuff here Faranth, very useful.

I do have a question, how do I have "Who is online" show the location.

IE:

Gio "Unknown"
main.php

To

Gio Test Page
test.php
This would all be done in the ./includes/functions_online.php file. I'll let Faranth finish this up as it is his "HowTo" thread.
Reply With Quote
  #57  
Old 02-11-2004, 03:39 PM
AndrewD AndrewD is offline
 
Join Date: Jul 2002
Location: Scotland
Posts: 3,486
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the recommended way to install/upgrade the series of templates used with a hack? (I know htl deals with this but...) Installing the templates manually is a pain and error prone, as is asking the user to go to the admin cp and upload the xml file.

How does one create a new template group?

I imagine one has to install/overwrite the templates in the base style(s). As a hack is being developed (and templates changed), one also has to be sure that any modified templates in the main and other styles are flagged.

I'm sure that tips on these points would be most welcome.
Reply With Quote
  #58  
Old 02-11-2004, 04:55 PM
Sent1nel Sent1nel is offline
 
Join Date: Feb 2004
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Edit: Sorry I got told off for posting in the wrong forum.

I fixed the problem and to simply make a new page which utilises existing stylesheets and headers, technically all you need to do is:

1. Create Custom Template with everything you Require - Ensure you include your header, footer etc references, shown below.

PHP Code:
{htmldoctype}
<
html>
<
head>
  <
titleBlah </title>
  
$headinclude
</head>
<
body>
$header

BLAHBLAHBLAHBALH

$footer

</body>
</
html
2. In your new page - use the below code to invoke your template. (My Custom template was called "blah").

PHP Code:
<?php
  $templatesused 
"blah";
  include(
"./global.php");
  eval(
"dooutput(\"".gettemplate("blah")."\");");
?>
Tony.
Reply With Quote
  #59  
Old 02-12-2004, 01:23 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 Sent1nel
Edit: Sorry I got told off for posting in the wrong forum.

I fixed the problem and to simply make a new page which utilises existing stylesheets and headers, technically all you need to do is:

1. Create Custom Template with everything you Require - Ensure you include your header, footer etc references, shown below.

PHP Code:
{htmldoctype}
<
html>
<
head>
  <
titleBlah </title>
  
$headinclude
</head>
<
body>
$header

BLAHBLAHBLAHBALH

$footer

</body>
</
html
2. In your new page - use the below code to invoke your template. (My Custom template was called "blah").

PHP Code:
<?php
  $templatesused 
"blah";
  include(
"./global.php");
  eval(
"dooutput(\"".gettemplate("blah")."\");");
?>
Tony.
Your methdo should only work for vB2 $templateused is no longer a valid varible in vB3
Reply With Quote
  #60  
Old 02-17-2004, 09:24 PM
tehste tehste is offline
 
Join Date: Feb 2004
Posts: 221
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I am making a mod and im new to VB but Im a fast learner.

I want to load a template called (test) inside test i want to put rows from a db table (test) with value1|value2|value3 i want to print the 3values for each row in the table and display them in the html defined in the (test2) template... and then load the rest of the (test) template. Is this possible?

Another question is: Would cases be suitable rather than all the ifs? or are ifs better?
thanks for help.
Reply With Quote
  #61  
Old 03-16-2004, 02:43 PM
kontrabass kontrabass is offline
 
Join Date: Feb 2002
Posts: 139
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry for the stupid question -

How does one pass a variable from a php script TO the template?

I've got a file, page.php, that includes the basic instructions in the first post in this thread, ending with (eval('print_output("' . fetch_template('my_template') . '");');

It works great - 'my_template' contains $header, some html, $footer, and it renders the page as expected.

However, in page.php I also define a variable $output = "some output"; I put $output in 'my_template' but it does not print out "some output" as expected.

Again sorry I'm probalby out of my legue here but if there's an easy way to do this please let me know!

TIA!
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 02:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04728 seconds
  • Memory Usage 2,344KB
  • 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
  • (8)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
  • (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