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! |
#72
|
||||
|
||||
I include a file but its showing me this error
Quote:
My file code is PHP Code:
|
#73
|
|||
|
|||
I''m not sure where query_read_slave is loaded. Did you try loading the hook in global_start?
|
#74
|
||||
|
||||
You should be using $vbulletin->db... to access queries, data, and the like... try this code:
PHP Code:
|
#75
|
|||
|
|||
Can I add 2 plugins like this?
--------------- Added [DATE]1332106295[/DATE] at [TIME]1332106295[/TIME] --------------- Nevermind, got it. All you have to do is change bot $php_include variables and the array name to the same thing. |
#76
|
|||
|
|||
Thanks it works perfectly, they should update or make more clear the vBulletin manual...
--------------- Added [DATE]1332297428[/DATE] at [TIME]1332297428[/TIME] --------------- Hello Crimm, Thanks very much for your post about including PHP files ... It was much more clear than in the manual. I followed your instructions and everything works fine for the forum, but in the CMS the PHP file is not included. I tried to fix it by adding: PHP Code:
|
#77
|
|||
|
|||
Hello,
If would like to use many PHP files on URL can we do something like: PHP Code:
?????????? |
#78
|
|||
|
|||
You should be able to do this (use ob_get_clean() instead of ob_get_contents()):
Code:
ob_start(); require_once('LOCATION OF EXTERNAL FILE'); $php_include = ob_get_clean(); require_once('LOCATION OF EXTERNAL OF SECOND FILE'); $php_include_SECOND_FILE = ob_get_clean(); ob_end_clean(); vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include)); vB_Template::preRegister('TEMPLATE YOU ARE USING FOR SECOND FILE',array('php_include' => $$php_include_SECOND_FILE)); I think if you want you could also put a preRegister call after each call to ob_get_clean() so you wouldn't need a bunch of different variables. |
#79
|
|||
|
|||
I've tried the following code. But whenever you click a user thread, no matter what thread you click, it always brings us to the same thread.
Code:
ob_start(); require_once('/home/ihatejob/revenantgaming.com/forum/modules/slidermodule.php'); $php_include = ob_get_clean(); ob_end_clean(); vB_Template::preRegister('adv_portal',array('php_include' => $php_include)); |
#80
|
|||
|
|||
Hello guys,
I finally achieved it!! I did a small tutorial about making External PHP files that can be used as Widgets in vBulletin CMS. I do not know if I can post links here ... but here is the tutorial ... I think someone might find it useful in the future. http://www.hyperlinkbuilding.org/con...idget-Tutorial Greetings, Eddie --------------- Added [DATE]1341004474[/DATE] at [TIME]1341004474[/TIME] --------------- I have to say something else ... Thanks a lot for trying helping me!! I will help others whenever I can. |
#81
|
||||
|
||||
I am helping a friend out to try and display his wordpress header above his vb forums header, im using the code below in the plugin and calling it in the header template:
Code:
ob_start(); require_once('http://al-hussain.co.uk/wp- content/themes/Karma/header.php'); $php_include = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('Test',array('php_include' => $php_include)); Code:
Warning: require_once() [function.require-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in [path]/includes/class_bootstrap.php(106) : eval()'d code on line 3 Warning: require_once(http://al-hussain.co.uk/wp- content/themes/Karma/header.php) [function.require-once]: failed to open stream: no suitable wrapper could be 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 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|