SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 187 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


This is an example of a function we could use to handle that event:
$mainframe->registerEvent('onPrepareFoobar',
'plgFoobarMyPluginPrepareFoobar');
/**
* Makes the name of the foobar uppercase.
*
* @param Foobar Reference to a Foobar object
*/
function plgFoobarMyPluginPrepareFoobar(&$foobar)
{
$foobar->name = strtoupper($foobar->name);
}
The most striking part of this function is the parameter. Earlier in this chapter, we
described how to trigger an event and we passed an array; each element of that array
is passed as a separate parameter to the listeners. In this example we can assume
that the one parameter is the Foobar object, which we passed by reference in the
triggering events example.
A single plugin can contain multiple functions for handling
multiple events.
If we want to create a listener using a class, we extend the abstract class JPlugin.
Before we start building a listener class, we must determine the name for the
class. JPlugin subclasses follow a special naming convention: the word plg, the
name of the plugin group, the name of the plugin element.


Pages:
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199