Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[How-to] Hooks and Plugins
calorie
Join Date: May 2003
Posts: 2,804

by calorie calorie is offline 11 Jun 2005

In hooks_vbulletin.xml you will see things like the following:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The hooktype is just a unigue name for the hook tags within. The hook tags refer specifically to PHP code in the vB files.

The PHP code in the vB files looks like the following:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Note how global_start is in a hook tag in hooks_vbulletin.xml and also in the vB PHP code.

To make a plugin hooked to global.php, you create an XML file as follows:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The place in vB PHP code where your global_start plugin runs is where the following occurs in global.php:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Basically, you make plugins via XML and your plugins hook to vB PHP code
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This latter example runs the first batch of PHP code where the following occurs in global.php:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And runs the second batch of PHP code where the following occurs in index.php:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Again, note how <hookname>hook_name</hookname> in the XML plugin
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:

- http://www.vbulletin.org/forum/showp...9&postcount=11

How to make a plugin:

- http://www.vbulletin.org/forum/showp...5&postcount=14

How to add a new hook location:

- http://www.vbulletin.org/forum/showp...01&postcount=1

Last edited by calorie; 22 Jun 2005 at 22:28..
Views: 8079
Reply With Quote
Comments
  #2  
Old 22 Jun 2005, 11:57
ojay ojay is offline
 
Join Date: Apr 2005
Lightbulb

the devkeys in the opening plugin tags mustn't be equal
Reply With Quote
  #3  
Old 22 Jun 2005, 22:27
calorie calorie is offline
 
Join Date: May 2003
Okay, thanks, updated.
Reply With Quote
  #4  
Old 23 Jun 2005, 01:20
Qualia Qualia is offline
 
Join Date: Jan 2003
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.
Reply With Quote
  #5  
Old 23 Jun 2005, 04:21
calorie calorie is offline
 
Join Date: May 2003
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."
Reply With Quote
  #6  
Old 23 Jun 2005, 10:02
Christine's Avatar
Christine Christine is offline
 
Join Date: Nov 2001
Real name: Christine. Really.
Thanks calorie -- nice job!
__________________
L'chaim
Reply With Quote
  #7  
Old 25 Jun 2005, 11:52
flup's Avatar
flup flup is offline
 
Join Date: Jan 2002
Real name: Joshua
I still don't understand much about the plugin and hooks... somebody should write a dutch how-to (Floris maybe?)
Reply With Quote
  #8  
Old 07 Jul 2005, 18:52
Highlander65 Highlander65 is offline
 
Join Date: Mar 2005
Are there restrictions on what can go inside the

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

For example:
  • Can we use a simple include or require statement for large code sections or functions?
  • Do we have length restrictions?
  • Can we make new SQL queries?
  • Is there any PHP code that can't be used?
  • Is there any PHP code that SHOULDN'T be used (different then can't)?


Stuff like that...
Thanks!
Reply With Quote
  #9  
Old 01 Aug 2005, 07:17
ToraTora! ToraTora! is offline
 
Join Date: Nov 2001
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.

Originally Posted by Highlander65
Are there restrictions on what can go inside the

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

For example:
  • Can we use a simple include or require statement for large code sections or functions?
  • Do we have length restrictions?
  • Can we make new SQL queries?
  • Is there any PHP code that can't be used?
  • Is there any PHP code that SHOULDN'T be used (different then can't)?


Stuff like that...
Thanks!
Most of the PHP code does work, but forget old functions such as the bbcode_parse or things along that nature.

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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Which worked. As long as I have that basis and get re-familiarized with many of the new variables, things should be pretty well back to normal within the plugin system, rather than creating a include script for my own created hacks.

Last edited by ToraTora!; 01 Aug 2005 at 08:17. Reason: Automerged Doublepost
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 05:07.

Layout Options | Width: Wide Color: