Add functions (pre/post/...) to an existing node
Appearance
|
ATK Howto: Add functions (pre/post/...) to an existing node
|
Modifiers allow you to modify nodes on before they are used. To add functions like preUpdate use atkTriggerListener
Example of using atkTriggerListener:
Add the following code in your module_preload.inc (if this file is not present, create it in your module's directory):
$modifiers[] = 'modules.node';
In your module.inc:
class mod_mymodule extends atkModule
{
public function module_node_modifier($node)
{
atkimport("module.mymodule.myListener");
$node->addListener(new myListener());
}
}
now setup class.myListener.inc. The Listner contain the new functions. They will be called automatically by the node.
atkimport("atk.utils.atktriggerlistener");
class MyListener extends atkTriggerListener
{
public function preUpdate( &$record )
{
do some code....
return true;
}
}