phpBB

Development Wiki

Difference between revisions of "Add Events"

From phpBB Development Wiki

(How to add a ledge)
(Moved to new docs)
 
(37 intermediate revisions by 10 users not shown)
Line 1: Line 1:
==So what are ledges==
+
This documentation has been moved to the new phpBB Development Documentation.
Ledges are hook locations. So what are hook locations? First you need to know what [[hooks]] are.
+
  
Ledges are the code injection points in the code. To use a hook the code inside the hook needs to be injected into the code in the right place. This can go in anywhere in the phpBB code base but it needs to have a ledge there.
+
[https://area51.phpbb.com/docs/dev/31x/extensions/tutorial_advanced.html#adding-a-php-event-to-your-extension Extensions: Adding a PHP event to your extension].
 
+
==How to add a ledge==
+
You would add a ledge as so:
+
<pre class="codebox"><nowiki> $phpbb_dispatcher->dispatch('identifer', $input_param); </nowiki> </pre>
+
Lets dissect that code
+
 
+
<pre class="narrow-codebox"><nowiki>$phpbb_dispatcher</nowiki></pre>
+
In phpBB this is automatically loaded, and there is also code that will load all the hook files (hook/*.php). It registers the hook containers of those files with the hooks controller.
+
 
+
<pre class="narrow-codebox"> <nowiki>dispatch</nowiki></pre>
+
This explains that you are adding a ledge.
+
 
+
<pre class="narrow-codebox"> <nowiki>identifer</nowiki></pre>
+
This is where you enter the name for the hook. If its in the core it should be prefixed by <pre class="narrow-codebox">core.</pre> but if its in an extension you should prefix it with something relating to your extension. This is to prevent clashes with other software.
+
 
+
<pre class="narrow-codebox"> <nowiki>$input_param</nowiki></pre>
+
This is where the input parameters go. If there is one it should be listed as it is in the example, if it is more than one then it should be in an array.
+
 
+
Based on the blog article [http://blog.phpbb.com/2010/10/09/explaining-hooks/ here]
+
[[Category:Ledges and Hooks]]
+

Latest revision as of 18:41, 5 December 2016

This documentation has been moved to the new phpBB Development Documentation.

Extensions: Adding a PHP event to your extension.