2008-06-08, 10:39 PM
Pages: 1 2
2008-06-09, 02:29 AM
Plugin... I'm guessing you know what one is.
Hooking is a technique typically used in plugins to inject code into various places.
Hooking is a technique typically used in plugins to inject code into various places.
2008-06-09, 07:30 PM
So for example..If you have...
<?php
$hook = new Hookname;
$hook->placeCode($text);
?>
The hook for 'Hookname', would place whatever is inside the "placeCode()" function?(ex: placeCode($text) { echo $text; })2008-06-09, 08:23 PM
No, the hooks in MyBB are places where you find code like:
Plugins "attach" themselves to hooks by running:
When the MyBB code reaches the run_hooks, the plugin system will find all the functions that were "attached" to the hook, and run those functions. Then it will continue the rest of the code.
$plugins->run_hooks('hook_name');
Plugins "attach" themselves to hooks by running:
$plugins->add_hook('hook_name', 'callback_function_to_run');
When the MyBB code reaches the run_hooks, the plugin system will find all the functions that were "attached" to the hook, and run those functions. Then it will continue the rest of the code.
2008-06-10, 12:33 AM
Sorry, but I'm confused..
2008-06-10, 12:43 AM
You could look up function pointers, but that might hurt you head more.
http://bisqwit.iki.fi/story/howto/php/#FunctionPointers
Think of a hook as a named callback. Essentially, you just register a function to be "called back" when the MyBB code hits the hook with the a certain name. Quite clever really, I never knew PHP could handle function pointers until now. (I know they're not "real" function pointers in PHP, but they behave in a similar way - also note the title of that webpage was "A guide into the PHP language for C++ programmers" - that's me ).
http://bisqwit.iki.fi/story/howto/php/#FunctionPointers
Think of a hook as a named callback. Essentially, you just register a function to be "called back" when the MyBB code hits the hook with the a certain name. Quite clever really, I never knew PHP could handle function pointers until now. (I know they're not "real" function pointers in PHP, but they behave in a similar way - also note the title of that webpage was "A guide into the PHP language for C++ programmers" - that's me ).
2008-06-10, 03:17 AM
So basically, a hook is a call to a plugins function that places code/html/a query result, etc, etc. - onto the page where the hook coding is placed in the file? Sorry to keep asking, but I just need a clarification..
2008-06-10, 03:21 AM
Yes, a hook will call a plugin's function. The function itself can do pretty much anything, the hook itself just acts like a trigger.
2008-06-10, 03:45 AM
And where is this function that would be called?
2008-06-10, 03:46 AM
(2008-06-10, 03:45 AM)dikidera Wrote: [ -> ]And where is this function that would be called?
In the plugin file.
Pages: 1 2