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! |
#32
|
|||
|
|||
![]()
o.k. I got that to work, now how to get scripts that call the same page to work?
|
#33
|
|||
|
|||
![]()
woooooooooooooooooooooow
very nice thanx thanx man gooood job ![]() exelent |
#34
|
|||
|
|||
![]()
How can I php file in my Sidebar include?
help ![]() |
#35
|
|||
|
|||
![]()
This is a nice tutorial you have, I have read many, but this one is very clear and simple. But from all the tutorials I've tried, I can never get this to work. I want to have a php file output into the postbit_legacy template. So I made a plugin following this tutorial, using this:
Hook Location: global_start Title: Testing Execution Order: 5 And the PHP Code: PHP Code:
PHP Code:
PHP Code:
Note: Where the "****" are, just for posting the code here, I put those in to censor where the files are, just to be safe. I really do have the correct paths in the files uploaded to the site. |
#36
|
|||
|
|||
![]()
Well global_start hook location is now obsolete as of 4.0.3+ and 4.1. You should probably use the global_bootstrap_init_start hook instead if you are using a recent version. Also using $php_include as your variable might be causing problems so rename it to something unique. Your plugin code should probably be more like this
Code:
ob_start(); require_once('http://www.xxxxxxx.com/creds.php'); $creds = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('postbit_legacy',array('creds' => $creds)); and of course the call in the postbit_legacy template {vb:raw creds} The parse error in your code is due to your missing the ";" at the end of your statement Quote:
|
#37
|
|||
|
|||
![]()
Thanks for the help. I tried all of that, and now every page in the forum is completely blank when I turn the plugin on. If I turn it off the forums are back. Is there any reason for this?
|
#38
|
||||
|
||||
![]()
I still don't understand why you guys just don't use the require_once to include the file in the php hook right before the code you want to use it with. You are taking the long way around doing it this way. Unless you need the included file for every page, it makes no sense to put it in the global hook.
|
#39
|
|||
|
|||
![]()
What version of vbulletin are you using?
If you type in the script location directly from your browser, does it work? If not, then its a problem with your script. Also, your php.ini might be set to disallow http php include calls, if you so need to enable it, or use the path call instead Code:
ob_start(); require_once('/path/to/your/website/creds.php'); $creds = ob_get_contents(); ob_end_clean(); vB_Template::preRegister('postbit_legacy',array('creds' => $creds)); |
#40
|
|||
|
|||
![]()
I'm using version 4.1.0. I tried changing my creds.php file to just simply echo "Test", and I still just get a plain white page on the forums. If I open the php file in my browser it correctly says Test. Should I change the hook location? Is there a better location for postbit_legacy? And I have copy pasted that code exactly in, and replaced the URL. What could be going wrong here? Thanks
Edit: I have noticed something else that is interesting. If I remove the {vb:raw creds} from the postbit_legacy template, there is still a blank page. If the plugin is on, theres a blank page, even if its not being called from the template. Hope this helps. |
#41
|
|||
|
|||
![]()
The plugin is fairly straight forward, as long as you have a valid script that you are calling and your plugin code is valid, you should be good to go.
you might have a php.ini config issue going on. Create a new file in your forum root, call it test.php Insert this <?php include ("/server/path/to/your/test.php"); ?> <?php include ("http://www.yoursite.com/forum/test.php"); ?> /insert this Then open the test.php in your browser If they BOTH work, you should have your echoed text inserted twice. If only ONE works, or you get a php error, you have a php.ini config issue to work out. |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|