View Full Version : what's the difference between plug-in, hook and hack-in?
TaMpE
04-29-2009, 09:19 PM
I was reading this : https://vborg.vbsupport.ru/showthread.php?t=82625
and found a few things that messed up my understanding and also fixed my other confusion but since there's new confusion, I want to know that difference before I choose the wrong path in case I get a larger forum.
Second thing, hooks will not get you into every corner of the code. Some things will always be done best with a hack. For example if you are looking to add something but need to query the db for some extra data and want to avoid and extra query (in other words you are going to modify an existing one with a join or such) forget it and hack it in, there are no hooks that let you modify existing queries.
Last but not least hooks are not magic, don't add a million of them and expect your forum to run as fast as it did when you first installed it. Only plug-in/hack-in what you really need!
and BTW, do all XML addon/mods we see here have <hookname>?
Lynne
04-29-2009, 09:31 PM
there are no hooks that let you modify existing queries.
This is no longer true. There are hooks in many queries now.
Usually a plugin is the actually code your write and it 'plugs into' a hook in the code. If you look at an actual hook in the code, it looks like this:
($hook = vBulletinHook::fetch_hook('group_dojoin')) ? eval($hook) : false;
In that case, you would write a plug-in which hooks into the hook located at "group_dojoin".
TaMpE
04-29-2009, 10:39 PM
This is no longer true. There are hooks in many queries now.
Usually a plugin is the actually code your write and it 'plugs into' a hook in the code. If you look at an actual hook in the code, it looks like this:
($hook = vBulletinHook::fetch_hook('group_dojoin')) ? eval($hook) : false;
In that case, you would write a plug-in which hooks into the hook located at "group_dojoin".
So the whole thing in the XML starting from <phpcode>EVERYTHING HERE</phpcode> go into that where group_dojoin ? Or the tag codes in <phpcode> replaces something below that hook ? Sorry, I still don't understand where the <phpcode> in XML go when it's plugged into the .php file or whatever we're adding to.
And could you explain in brief what's happening in this?
What do these do? This ".=" and the dots in between? I can't find a good place from eval explanation. Tried w3schools, any suggestion?
eval('$activeusers_members .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
$activeusers_members = substr($activeusers_members, 2);
Dismounted
04-30-2009, 07:30 AM
Do not edit the XML file directly. Create and edit plugins/templates in the Admin CP, and when you're done, export the XML. This prevents structural errors.
The ".=" you are talking about is the concatenation operator (I dare you to say it!) in PHP. It is used to append content onto the end of a variable, etc.
As for eval(), anything in between its parentheses is executed as PHP code. See the PHP Manual.
EnIgMa1234
04-30-2009, 11:06 AM
So the whole thing in the XML starting from <phpcode>EVERYTHING HERE</phpcode> go into that where group_dojoin ? Or the tag codes in <phpcode> replaces something below that hook ? Sorry, I still don't understand where the <phpcode> in XML go when it's plugged into the .php file or whatever we're adding to.
And could you explain in brief what's happening in this?
What do these do? This ".=" and the dots in between? I can't find a good place from eval explanation. Tried w3schools, any suggestion?
eval('$activeusers_members .= ", ' . fetch_template('forumhome_loggedinuser') . '";');
$activeusers_members = substr($activeusers_members, 2);
http://php.net/eval
TaMpE
04-30-2009, 03:24 PM
Do not edit the XML file directly. Create and edit plugins/templates in the Admin CP, and when you're done, export the XML. This prevents structural errors.
The ".=" you are talking about is the concatenation operator (I dare you to say it!) in PHP. It is used to append content onto the end of a variable, etc.
As for eval(), anything in between its parentheses is executed as PHP code. See the PHP Manual.
http://php.net/eval
thanks I'll have a read.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.