vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   what's the difference between plug-in, hook and hack-in? (https://vborg.vbsupport.ru/showthread.php?t=212466)

TaMpE 04-29-2009 08:19 PM

what's the difference between plug-in, hook and hack-in?
 
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.

Quote:

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 08:31 PM

Quote:

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:
PHP Code:

($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 09:39 PM

Quote:

Originally Posted by Lynne (Post 1801410)
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:
PHP Code:

($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?
PHP Code:

eval('$activeusers_members .= ", ' fetch_template('forumhome_loggedinuser') . '";');
                
$activeusers_members substr($activeusers_members2); 


Dismounted 04-30-2009 06: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 10:06 AM

Quote:

Originally Posted by TaMpE (Post 1801454)
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?
PHP Code:

eval('$activeusers_members .= ", ' fetch_template('forumhome_loggedinuser') . '";');
                
$activeusers_members substr($activeusers_members2); 


http://php.net/eval

TaMpE 04-30-2009 02:24 PM

Quote:

Originally Posted by Dismounted (Post 1801686)
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.

Quote:

Originally Posted by EnIgMa1234 (Post 1801743)

thanks I'll have a read.


All times are GMT. The time now is 04:18 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01828 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete