phpBB

Development Wiki

Difference between revisions of "Add Events"

From phpBB Development Wiki

(So what are ledges)
(Moved to new docs)
 
(33 intermediate revisions by 9 users not shown)
Line 1: Line 1:
==What are ledges?==
+
This documentation has been moved to the new phpBB Development Documentation.
A ledge is a hook location. When an extension wishes to hook its functionality into the phpBB core at a certain point, it can do so only at available hook locations, or ledges. For more information, see the wiki article for [[hooks]].
+
  
==How to add a ledge==
+
[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].
You would add a ledge like so:
+
<pre class="codebox"> <nowiki>$phpbb_dispatcher->dispatch('identifer', $input_param); </nowiki> </pre>
+
Let's dissect that code
+
 
+
<pre class="narrow-codebox"> <nowiki>$phpbb_dispatcher</nowiki></pre>
+
This is the phpbb_dispatcher object, which is automatically loaded with the page. This object registers the hook containers of found within hook files (in the hooks/*.php directory) with the hooks controller.
+
 
+
<pre class="narrow-codebox"> <nowiki>dispatch</nowiki></pre>
+
This method adds 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 "core." but if its in an extension you should prefix it with a unique string related to your extension to prevent clashes with other extensions.
+
 
+
<pre class="narrow-codebox"> <nowiki>$input_param</nowiki></pre>
+
This is where the input parameters go. This will either be a single variable or an array of variables, depending on the ledge onto which you are hooking.
+
 
+
Based on the blog article [http://blog.phpbb.com/2010/10/09/explaining-hooks/ Explaining Hooks]
+
[[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.