vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [How to] Write Plug-ins/Hooks (https://vborg.vbsupport.ru/showthread.php?t=82625)

Andreas 06-09-2005 06:15 PM

Hmm .... a Query class!
That's what would be needed.

Example
PHP Code:

$query->add_join($table$alias$condition);
$query->add_fields(array('field1''field2' => 'fieldalias'));
$query->add_condition($operator$condition);
... 


amykhar 06-09-2005 06:26 PM

Quote:

Originally Posted by KirbyDE
Hmm .... a Query class!
That's what would be needed.

Example
PHP Code:

$query->add_join($table$alias$condition);
$query->add_fields(array('field1''field2' => 'fieldalias'));
$query->add_condition($operator$condition);
... 


Exactly!

Fusion 06-09-2005 07:26 PM

Quote:

Originally Posted by KirbyDE
Hmm .... a Query class!
That's what would be needed.

Example
PHP Code:

$query->add_join($table$alias$condition);
$query->add_fields(array('field1''field2' => 'fieldalias'));
$query->add_condition($operator$condition);
... 


Actually, that's an excellent idea.

Revan 06-09-2005 09:12 PM

I have an addition to this tutorial:

[high]vbulletin_plugins.xml[/high]
If you need to tell your users to add a lot of plugins, this will become tedious as much copy/pasting is required. A simpler way would be to use the .xml import. It works just like the importing of templates and phrases, by adding the contained code as a Plugin.
The correct format for a plugin.xml file is like so (thanks to Live Wire):
Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
        <plugin active="1">
                <title>vB Category Icons</title>
                <hookname>forumdata_start</hookname>
                <phpcode><![CDATA[$this->validfields['forumhomeicon'] = array(TYPE_STR, REQ_NO);]]></phpcode>
        </plugin>
</plugins>

Explanations:
<plugin active="1"> - The 'active' attribute determines the default value of 'Plugin is Active' in the Plugin Manager.
<title></title> - Self explanatory, it is the 'Title' field in the Manager.
<hookname></hookname> - The 'Hook Location' you would select.
<phpcode><![CDATA[ ]]></phpcode> - Anything added in the space between these is added to the 'Plugin PHP Code' part.


// end my contribution (if this is being merged into the first post, nothing below this is to be included)

And just for all you lazy people out there, here is an empty set, ready for copypasting into a blank xml file (only the <?xml and <plugins> tags need to be there already):
Code:

        <plugin active="1">
                <title></title>
                <hookname></hookname>
                <phpcode><![CDATA[]]></phpcode>
        </plugin>

I hope this helps hack writers that want to minimise the hassle for the end-user :)

Cap'n Steve 06-10-2005 06:28 AM

Quote:

Originally Posted by Brad.loo
First and foremost plug-ins are stored in the database, serlized, unserlized and evaled on page generation. If you code preforms badly with such a wrapper forget making a plug-in and just hack it, trust me you'll thank yourself for it when your forum gets large.

Could you elaborate on this? Are there some known problems with eval() or something else?

Logikos 06-10-2005 06:45 AM

Quote:

Originally Posted by Cap'n Steve
Could you elaborate on this? Are there some known problems with eval() or something else?

What he means is, if your code is just;
PHP Code:

echo $threadid

You better off hacking it, as if you add it to the plugin area, it has to call a query just to call that line.

The above is just a stupid example for you to understand better. Obviously we won't be using a echo in our hacks.

Paul M 06-10-2005 06:54 AM

Quote:

Originally Posted by Revan
I have an addition to this tutorial:

<snip>

If you have developed the plugin on your own board then all you need do is use the plugin manager's download feature to create your ready made xml file for others to use.

Marco van Herwaarden 06-10-2005 08:43 AM

Guys (and girls) please don't use threads in the How-To's forum to say thank you or discuss things. Only post How-To's and additions to them so we can get clean instructions on how to solve problems.

Andreas 06-10-2005 02:15 PM

Something that might come in handy for those developing Plugins:

In class_hook.php FIND
PHP Code:

function &fetch_hook($hookname)


BELOW that ADD
PHP Code:

DEVDEBUG("Calling Hook $hookname"); 

Then (if debug mode is turned on) you can see which hooks are being called, and when they are being called.

dwh 06-15-2005 06:43 AM

I'm trying to get a handle on these hooks. What if you want to write custom code and just hook it into opening a new pm, or starting a new thread. How would that work?

Also is there a difference between a Plug-In and a Hook or are they the same thing?


All times are GMT. The time now is 09:09 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.01089 seconds
  • Memory Usage 1,755KB
  • 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
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete