The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[vBulletin 4] Simple way of including an external PHP file
There are other articles out there on variables, templates, etc on vBulletin 4. This is a simple example of including an external PHP files like you used to be able to do here: http://www.vbulletin.com/forum/showt...P-or-HTML-File Thanks to this Blog post by David IB http://www.vbulletin.com/forum/entry...s-to-templates and this article by cellarius https://vborg.vbsupport.ru/showthread.php?t=228078 I have figured out it's only a simple extra step. Step 1: Create a new plugin
Step 2: You will have to figure out these two entries for yourself: LOCATION OF EXTERNAL FILE & Hook Location To give you an example of what you should use is that if you want to display your external PHP file on your Forum's Home. Then replace these two with these values: Hook Location with forumhome_start TEMPLATE YOU ARE USING with FORUMHOME Keep in mind that global_start will still be acceptable, but it's extra loading time where it's not needed. Therefore choosing the optimum hook location is better for your performance overall. Step 3: Visit the Style Manager -> TEMPLATE YOU ARE USING and place the variable in your style where you want it. You will have to use the new format. Code:
{vb:raw php_include} Notes, If you want to: Include this PHP file in multiple templates then preRegister it for the multiple templates: Code:
vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include)); vB_Template::preRegister('TEMPLATE YOU ARE USING 2',array('php_include' => $php_include)); I'm still learning as I go with vb4, but if I learn some more notes to add... I'll drop by here. I hope that helps some one out there! |
#82
|
|||
|
|||
check your php.ini and server configurarion ... I think you cannot require_once an URL ....
|
#83
|
||||
|
||||
Ive set allow_url_include=1 in php.ini now that gets rid of the first error, still the other two errors:
Code:
Warning: require_once(http://al-hussain.co.uk/wp- content/themes/Karma/header.php) [function.require-once]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in [path]/includes/class_bootstrap.php(106) : eval()'d code on line 3 Fatal error: require_once() [function.require]: Failed opening required 'http://al-hussain.co.uk/wp- content/themes/Karma/header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/alhussai/public_html/forum/includes/class_bootstrap.php(106) : eval()'d code on line 3 Any ideas guys? |
#84
|
|||
|
|||
Sorry, i have no idea... but i think it has to do with the streams or paths ...
|
#85
|
||||
|
||||
You can't do a require_once on an http:// URL... you can only require (or include) on a local file on your server and it has to be by a local path.
|
#86
|
||||
|
||||
Quote:
Code:
ob_start(); require_once('/home/alhussai/public_html/wp- content/themes/Karma/header.php'); $php_include = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('Test',array('php_include' => $php_include)); |
#87
|
|||
|
|||
I noticed in the error message above and in the one you posted on vbulletin.com that there's a space between wp- and content. It should be all one word, so maybe try taking out whatever character that is (so it reads require_once('/home/alhussai/public_html/wp-content/themes/Karma/header.php', all on one line).
|
#88
|
||||
|
||||
Thanks for the reply the error seem to have gone and now its giving just this:
Code:
Fatal error: Call to undefined function language_attributes() in /home/alhussai/public_html/wp-content/themes/Karma/header.php on line 2 Removed language_attributes() from header.php now just a blank page now errors :/ |
#89
|
|||
|
|||
I think the header.php is depending on some Wordpress functions that you aren't including.
|
#90
|
|||
|
|||
Hello,
am a new Owner of vb4.2 and would like to add an echo Script. Unfortunately, this does not in the Templates, the Output will always appear at the top left. What can I do? I use the Standart Style! Please help me.. I have add a Plugin: PHP Code:
HTML Code:
{vb:raw back} The same Script tested in the Customer Sidebar, thats Works fine |
#91
|
|||
|
|||
Try this:
Code:
ob_start(); include('/var/www/virtual/htdocs/echo.php'); echo $back; $output = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('template',array('back' => $output)); (you may not need the ob_get_contents(), but I'm not sure if the echo script creates any output other than the $back value). |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|