phpBB

Development Wiki

Difference between revisions of "Add Events"

From phpBB Development Wiki

(How to add a ledge)
(So what are ledges)
Line 1: Line 1:
==So what are ledges==
+
==What are ledges?==
Ledges are hook locations. So what are hook locations? First you need to know what [[hooks]] are.
+
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]].
 
+
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.
+
  
 
==How to add a ledge==
 
==How to add a ledge==

Revision as of 20:35, 10 March 2012

What are ledges?

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

You would add a ledge like so:

 $phpbb_dispatcher->dispatch('identifer', $input_param);  

Let's dissect that code

 $phpbb_dispatcher

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.

 dispatch

This method adds a ledge.

 identifer

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.

 $input_param

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 Explaining Hooks