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
  #102  
Old 01-29-2005, 07:56 PM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery
You didnt print any templates...

your missing the most important line

eval('print_output("' . fetch_template('TEMPLATE') . '");');

You just made some varibles, you didnt tell the script to display a template i suggest trying generic shell

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');
Gosh that would have saved me a lot of time had I known about it. Howdo use it? How do you populate $HTML? Is it a regular variable or aspecial one?

Also, I still don't get actions? Can someone explain the system in more details?
Reply With Quote
  #103  
Old 01-31-2005, 10:40 PM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I understood actions now. It's no big deal it just pulls outany templates that are defined (somewhere? init.php?) for that action.It's a "shortcut" but it doesn't make any difference as long as youpull out any template you use in globaltemplates you should be ok.Correct me if I'm wrong.

I'd still like to know about the $HTML thing though.
Reply With Quote
  #104  
Old 02-01-2005, 07:51 PM
feldon23's Avatar
feldon23 feldon23 is offline
 
Join Date: Oct 2001
Posts: 124
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dwh
I think I understood actions now. It's no big deal it just pulls outany templates that are defined (somewhere? init.php?) for that action.It's a "shortcut" but it doesn't make any difference as long as youpull out any template you use in globaltemplates you should be ok.Correct me if I'm wrong.

I'd still like to know about the $HTML thing though.
I'm using this code and to get images and javascript to load, I'm having to use ugly search-and-replace code that replaces

href=" with href="../forums/

and

src=" with src="../forums/, etc.

There's got to be an easier way.

The huge problem I am running into now is that by including global.php, and by extension init.php, cookies are being established. That's not what I want. Is there a way to load templates without all that other stuff happening?

What I may need to do is create a cron task that dumps the evaluated contents of the templates I need to flat HTML files and then include those.
Reply With Quote
  #105  
Old 04-10-2005, 10:29 PM
Razz Razz is offline
 
Join Date: Dec 2001
Location: UK
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If your using the action templates as shown in the original post:

PHP Code:
$actiontemplates = array(
                            
'small' => array(
                                                     
'other'
                                                    
)
); 
along with:

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

Then you will need to set a default action template like below:

PHP Code:
$actiontemplates = array(
                            
'small' => array(
                                                     
'other'
                                                    
)
);

$actiontemplates['none'] = &$actiontemplates['small']; 
This should prevent uncached templates on initial page visit if $_REQUEST['do'] is empty. Just change "small" in the last line to the default template array such as "home" or "main".
Reply With Quote
  #106  
Old 04-30-2005, 12:36 AM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi

I've got the page to work, but I'd like to use a custom header and footer because the links do not show correctly at present - I've created the new templates for them and called them in my 'test' template instead of the standard ones. But it doesnt work :-(

Can someone give me a quick run-down of how it can be achieved? thanks.
Reply With Quote
  #107  
Old 04-30-2005, 03:54 PM
NxTek NxTek is offline
 
Join Date: Jun 2003
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can that be used for this (from another post) -

I've seen a few scripts that prompt a user to login, but nothing that would redirect the user to the internal login page on non-vB pages.

I have a directory structure like this -

/forums
/ads
/games
/faqs
/blog
and so on.

I want to use vB security throughout my entire site, even outside the actual /forums dir.

If you would go straight to /blog/blog.php for example, a piece of code would detect whether the visitor is logged in or not.

If so, display the page normally.

If not, redirect them to the exact same login screen that's invoked when you go to http://www.onlinepokerlistings.com/forums/calendar.php.

Ok, after logging in, the visitor would be directed back to /blog/blog.php.

It would work exactly the same as normally requiring a login to see a vB page, but in this case it's outside of vB.
Reply With Quote
  #108  
Old 08-21-2005, 01:51 AM
hexosex hexosex is offline
 
Join Date: Aug 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where the hell are the templates stored? :O I just cant find them on the installation i have here... Can anyone help please?
Reply With Quote
  #109  
Old 08-21-2005, 02:33 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the database (you should access them from vBulletin).

AdminCP > Style Manager > (pick a style) > Edit Templates
Reply With Quote
  #110  
Old 09-16-2005, 04:56 PM
lem's Avatar
lem lem is offline
 
Join Date: May 2005
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have this system setup for my site locksmithcafe.com. However, when I log out of the forum and go to locksmithcafe.com it gives me the following error:

Quote:
Unable to add cookies, header already sent.
File: /home/httpd/vhosts/locksmithcafe.com/httpdocs/index.php
Line: 9

whats up with that do you think?

Here is my index.php page:

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Welcome to the Locksmith Cafe!</title>
</head>

<body>
<?php 
// OUR CONTENT BEGINS ON LINE 48 -----------------------------------------
// ## 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 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( 
'headinclude',
'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('$h_include = "' fetch_template('headinclude') . '";'); 
eval(
'$header = "' fetch_template('header') . '";'); 
//eval('$navbar = "' . fetch_template('navbar') . '";'); 
eval('$footer = "' fetch_template('footer') . '";'); 

//eval('print_output("' . fetch_template('headinclude') . '");');

echo $h_include;
echo 
$header;
//echo $navbar;
// ********************************************************************************
// place our content here *********************************************************

echo '
<h3>Welcome to the Locksmith Cafe!</h3>

<br><br><br><br>
<h3>Find a Locksmith in Your area!</h3>
'
;
include 
$_SERVER['DOCUMENT_ROOT'].'/search.html';
// end our content ****************************************************************
// ********************************************************************************
echo $footer;
?>
</body>
</head>
Any ideas?

thanks

Lem
Reply With Quote
  #111  
Old 09-16-2005, 04:59 PM
hexosex hexosex is offline
 
Join Date: Aug 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are trying to start another page that is trying to set the http headers after they have allready been set. I had this problem and got around it with some php http posts that then caught the output stripped out the headers and then set them on final output!

Contact me gary@behindtheweb.co.uk if you need any more help on this problem. I'd be happy to 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 06:50 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.05018 seconds
  • Memory Usage 2,356KB
  • 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
  • (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