vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using External PHP Pages (https://vborg.vbsupport.ru/showthread.php?t=269457)

nima6 08-31-2011 02:58 PM

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.

kh99 08-31-2011 03:07 PM

You need to add this:

PHP Code:

vB_Template::preRegister('FORUMDISPLAY', array('includedheader' => $includedheader)); 


nima6 08-31-2011 03:31 PM

Thanks

Where would i include that?

Lynne 08-31-2011 03:37 PM

<a href="https://vborg.vbsupport.ru/showthread.php?t=242454" target="_blank">[vBulletin 4] Simple way of including an external PHP file</a>

kh99 08-31-2011 03:51 PM

Quote:

Originally Posted by nima6 (Post 2240461)
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. :o

nima6 08-31-2011 04:25 PM

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

kh99 08-31-2011 04:46 PM

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).

ICThawk 08-31-2011 05:40 PM

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.

kh99 08-31-2011 05:50 PM

Quote:

Originally Posted by ICThawk (Post 2240523)
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.

nima6 08-31-2011 06:14 PM

Quote:

Originally Posted by kh99 (Post 2240504)
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)


All times are GMT. The time now is 04:22 AM.

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.01063 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete