The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[How-to] Hooks and Plugins
In hooks_vbulletin.xml you will see things like the following: Code:
<hooktype type="general"> <hook>global_start</hook> <hook>global_complete</hook> The PHP code in the vB files looks like the following: Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false; To make a plugin hooked to global.php, you create an XML file as follows: Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <plugins> <plugin active="1" devkey="Name" product="vbulletin"> <title>Your Title</title> <hookname>global_start</hookname> <phpcode><![CDATA[// // START PHP CODE $foo = "bar"; // END PHP CODE //]]></phpcode> </plugin> </plugins> Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false; via <hookname>hook_name</hookname> from the plugins, which needs to match the fetch_hook('hook_name') in the vB PHP code, which needs to match <hook>hook_name</hook> in hooks_vbulletin.xml. You can even make a plugin that hooks to multiple vB PHP files as follows: Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <plugins> <plugin active="1" devkey="Name1" product="vbulletin"> <title>Your Title1</title> <hookname>global_start</hookname> <phpcode><![CDATA[// // START PHP CODE1 $foo = "bar"; // END PHP CODE1 //]]></phpcode> </plugin> <plugin active="1" devkey="Name2" product="vbulletin"> <title>Your Title2</title> <hookname>forumhome_start</hookname> <phpcode><![CDATA[// // START PHP CODE2 $bar = "foo"; // END PHP CODE2 //]]></phpcode> </plugin> </plugins> Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false; Code:
($hook = vBulletinHook::fetch_hook('forumhome_start')) ? eval($hook) : false; matches fetch_hook('hook_name') in the vB PHP code matches <hook>hook_name</hook> in hooks_vbulletin.xml. Further readings... What is a hook: - https://vborg.vbsupport.ru/showpost....9&postcount=11 How to make a plugin: - https://vborg.vbsupport.ru/showpost....5&postcount=14 How to add a new hook location: - https://vborg.vbsupport.ru/showpost....01&postcount=1 |
#2
|
|||
|
|||
the devkeys in the opening plugin tags mustn't be equal
|
#3
|
|||
|
|||
Okay, thanks, updated.
|
#4
|
|||
|
|||
calorie, Thank you for explaining that. I had someone tell me what a hook was and I kind of got my brain wrapped around the idea, but you finished off the explaination really well. I'm a visual thinker and the way you explained how this will work was good for me.
|
#5
|
|||
|
|||
Thanks. KirbyDE was helping me to understand, along with the authors of the other posts I listed, so I'm glad that you found it useful, and that I got to "pay it forward."
|
#6
|
||||
|
||||
Thanks calorie -- nice job!
|
#7
|
||||
|
||||
I still don't understand much about the plugin and hooks... somebody should write a dutch how-to (Floris maybe?)
|
#8
|
|||
|
|||
Are there restrictions on what can go inside the
Code:
//Start PHP Code //End PHP Code
Stuff like that... Thanks! |
#9
|
|||
|
|||
I have ran into several roadblocks on this new plugin situation and it is frustrating to say the least.
Entering in SQL queries seem to work, but eval codes for template calls (even by the new standard like error templates) cause errors. I am pretty sure it is user error on my end, but what would be really nice to see for once is a real life example of a mysql plugin-template exchange within a plugin so we have a general idea of what needs to be done in order to make it work properly. Ok, starting to get the hang of it. I still prefer the old way of simply creating a include script to handle all of my hacks, but I can also see where the plugin manager will be beneficial for many areas such as a seperate front page with left, middle and right columns similar to the old Nuke class system. Quote:
The SQL queries will work as well, but you have to use the new format which was posted by VBLuke earlier, in which Keir created a document on those new settings. A example of what I did with just a very elementary and simple condition within a plugin was this: Code:
if ($vbulletin->userinfo['userid'] == 1){ echo "You are the admin and this should load a template"; eval('print_output("' . fetch_template('FORUM_STANDOFF') . '");'); } else { echo "Well that sucked didnt it?"; } |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|