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! |
#22
|
|||
|
|||
Quote:
any generous person wants to share his knowledge ? --------------- Added 11 Dec 2010 at 03:23 --------------- would any kind person help with this ? |
#23
|
||||
|
||||
postbit_display_complete is a php code hook... not a template... the template is named postbit and it's the same in VB3 and VB4.
|
#24
|
||||
|
||||
Nice idea i will give this a try ..........
|
#25
|
|||
|
|||
Hi everybody,
sorry in advance for me maybe talking rubbish, but I am completely new to developing plugin code for vbulletin. I am quite experienced in coding PHP, though. Boofo pointed me in the right direction (thanks for that), but, however, I am still facing the following problem: I want to extend the list of online users (online.php) by another column. Information within that column is not extracted from the database but fetched from a third party. This has to be done for each user that shows up in the list of online users - but I have no idea which hook I may use. At the moment, my plugin works pretty fine - but it is a bad mixture of source code hacking and template modifications. If any future upgrade replaces online.php, all my changes are gone. I added a very few lines of code in online.php (v4.1.0 PL2) starting from line 414, which basically adds another value to the $userinfo array which (as if this variable is registered) can be accessed from the whoisonlinebit template, where the output is generated from the additional value. As mentioned before - so far, everything works fine but I truly hate source code modifications as they are gone after an update. Therefore, it would be great to know if there is another way of executing code (maybe in an external file) for each line in the result set. If I interpret the PHP source in online.php correctly, anything that should be executed for each user name should go inside the while loop on line 393. The instructions above explain how to use external files with hooks but I just can't figure out which hook to use in that case... Is there a way to execute PHP code from templates without having a hook? As I said, I am completely new to this stuff, please help... |
#26
|
||||
|
||||
There's a hook at the very end of the while loop:
PHP Code:
|
#27
|
|||
|
|||
Indeed, I have found that hook and I thought it would be what I was looking for, but obviously this hook only affects spiders/guests, according to the comment on line 449:
PHP Code:
|
#28
|
||||
|
||||
Probably not... although it's of no use when releasing a mod to others you can add your own hooks to the code anywhere you want- so if it's just for you adding a 1 line hook and keeping the bulk of the code in a plugin will make life easier than keeping all edits in the files.
|
#29
|
|||
|
|||
Thanks for replying to fast! Well, that of course would be possible and still, this is probably the best idea. I still could add instructions on how to create the custom hook in my install guide. However, I consider this hook a bug... I just can't believe it makes any sense in that position. But as mentioned before, I am quite new to this plugin system, probably I just do not understand enough...
But am I right that there is no way to achieve what I want without modifying the original vb source code? |
#30
|
||||
|
||||
Quote:
However if you're fetching data from an external source could you not just "run the loop" a second time and collect the data needed per user id, and put the data in an array who's keys are the userid's themselves so it's say $mydata[1] for userid 1, $mydata[200] for user 200, etc... then call it in the template where needed (after pre-registering it of course.) |
#31
|
|||
|
|||
PHP Code:
global bootstrap init start, is the hook I am using. I had some bugs in the code when I first included it, and it showed up as I worked the bugs out, and the code ran clean, it made it through the hook. Thats great. I clicked on the tab, that is linked to the template I added it to, and it just wont display Ideas anybody? RG |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|