Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Articles Thread, [How-to] Hooks and Plugins in vBulletin; [How-to] Hooks and Plugins In hooks_vbulletin.xm l you will see things like the following: Code: PHP Code: < hooktype type ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3855


Reply
LinkBack Thread Tools Display Modes
[How-to] Hooks and Plugins
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
28-09-2008, 07:55 PM
 
[How-to] Hooks and Plugins


In hooks_vbulletin.xm
l you will see things like the following:
Code:
PHP Code:
<hooktype type="general">
        <
hook>global_start</hook>
        <
hook>global_complete</hook>
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:
Code:
PHP Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false;
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:
Code:
PHP 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>
The place in vB PHP code where your global_start plugin runs is where the following occurs in global.php:
Code:
PHP Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false;
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:
Code:
PHP 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>
This latter example runs the first batch of PHP code where the following occurs in global.php:
Code:
PHP Code:
($hook = vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false;
And runs the second batch of PHP code where the following occurs in index.php:
Code:
PHP Code:
($hook = vBulletinHook::fetch_hook('forumhome_start')) ? eval($hook) : false;
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.
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
28-09-2008, 08:08 PM
 
What is a hook

PHP Code:
http://forum.egypt.com/enforum/articles-f145/what-hook-3856.html
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Articles Thread, [How-to] Hooks and Plugins in vBulletin; [How-to] Hooks and Plugins In hooks_vbulletin.xm l you will see things like the following: Code: PHP Code: < hooktype type ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3855


Bookmarks

Tags
hooks, howto, plugins


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PTC autoclicker + plugins Developer Software and Programs 0 17-12-2008 07:15 PM
Foobar plugins (DSP) Developer Software and Programs 0 04-11-2008 01:59 AM
ProgDVB Plugins by den78 Developer Software and Programs 0 08-10-2008 08:25 PM
Universal Share Downloader + Plugins (1.3.5.1) Developer Software and Programs 0 07-10-2008 02:07 PM
Hooks in vBulletin 3.7.x Developer Articles 0 10-09-2008 06:58 PM