Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2011, 02:58 PM
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using External PHP Pages

Im trying to include an external php file in the VB template. I found this tutorial. I've added the following plugin with Global_Start as the Hook Location.

Plugins are Enabled in VB Options and the plugin itself is activated too.

Code:
ob_start();  include('/home/.../bh_includes/head_common.php');
  $includedheader = ob_get_contents();
  ob_end_clean();
And then I'm calling for {vb:raw includedheader} in the FORUMDISPLAY file.

Nothing is showing up in my template though.
Reply With Quote
  #2  
Old 08-31-2011, 03:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to add this:

PHP Code:
vB_Template::preRegister('FORUMDISPLAY', array('includedheader' => $includedheader)); 
Reply With Quote
  #3  
Old 08-31-2011, 03:31 PM
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks

Where would i include that?
Reply With Quote
  #4  
Old 08-31-2011, 03:37 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=242454" target="_blank">[vBulletin 4] Simple way of including an external PHP file</a>
Reply With Quote
  #5  
Old 08-31-2011, 03:51 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nima6 View Post
Thanks

Where would i include that?
At the end, as in the article Lynne linked to. And sorry, BTW, what I posted actually had an error in it.
Reply With Quote
  #6  
Old 08-31-2011, 04:25 PM
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So this is what i have right now:

Code:
ob_start();  include('/home/XXXX/public_html/bh_includes/head_common.php');
  $includedphp = ob_get_contents();
  ob_end_clean();
vB_Template::preRegister('header', array('includedheader' => $includedheader));
And using {vb:raw includedheader} in the "header" file in the template.

Its still not working
Reply With Quote
  #7  
Old 08-31-2011, 04:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I probably confused you with my error. This should work:

PHP Code:
ob_start();  
include(
'/home/XXXX/public_html/bh_includes/head_common.php');
$includedphp ob_get_contents();
ob_end_clean();
vB_Template::preRegister('header', array('includedheader' => $includedphp)); 

with this in the header template: {vb:raw includedheader}

(the variable names needed to match in the ob_get_contents() and preRegister lines).
Reply With Quote
  #8  
Old 08-31-2011, 05:40 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a very similar question. My site is www.wavingthewheat.com

I am using a php script to count the number of rows in a table on the database. The script is loaded at www.wavingthewheat.com/chatuser.php

I am trying to have the output of that file displayed in my navbar template. I have created a plugin with the following code

PHP Code:
ob_start();
  include(
'/home/bluepr12/public_html/wavingthewheat.com/chatuser.php');
  
$includedphp ob_get_contents();
  
ob_end_clean();

vB_Template::preRegister('nabvar',array('includedphp ' => $includedphp)); 
In my navbar template I have {vb:raw includedphp} as part of the Chat link.

The php script works and displays the number of online users, however I can't get anything to display in the template using the plugin.
Reply With Quote
Благодарность от:
nima6
  #9  
Old 08-31-2011, 05:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ICThawk View Post
The php script works and displays the number of online users, however I can't get anything to display in the template using the plugin.
It looks like you've misspelled 'navbar' in your preregister call.
Reply With Quote
Благодарность от:
nima6
  #10  
Old 08-31-2011, 06:14 PM
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Sorry, I probably confused you with my error. This should work:

PHP Code:
ob_start();  
include(
'/home/XXXX/public_html/bh_includes/head_common.php');
$includedphp ob_get_contents();
ob_end_clean();
vB_Template::preRegister('header', array('includedheader' => $includedphp)); 

with this in the header template: {vb:raw includedheader}

(the variable names needed to match in the ob_get_contents() and preRegister lines).


That worked. Thanks a bunch.

--------------- Added [DATE]1314819916[/DATE] at [TIME]1314819916[/TIME] ---------------

I must the most idiot on this forums.

I'm trying to include a second php file (for footer this time) and am having problems again.

This time this is what im using:

Code:
ob_start();   
include('/home/XXXX/public_html/bh_includes/footer-common.php'); 
$includedfphp = ob_get_contents(); 
ob_end_clean(); 
vB_Template::preRegister('footer', array('includedfooter' => $includedfphp));
and {vb:raw includedfooter}

That doesnt work either. I changed the includedphp to includedfphp because using just the includedphp didnt work. I assumed it was because that variable was already being used elsewhere so i changed it (nothing happened though)
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:25 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.04365 seconds
  • Memory Usage 2,275KB
  • Queries Executed 13 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (4)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete