Jump to content

Add functions (pre/post/...) to an existing node: Difference between revisions

From NusaATK
Woody (talk | contribs)
New page: {{howto|Advanced|Thomas Holz <vhskids@gmx.de>}} Modifiers allow you to modify nodes on before they are used. To add functions like preUpdate use atkTriggerListener '''Example of usi...
 
Woody (talk | contribs)
No edit summary
Line 1: Line 1:
{{howto|Advanced|[[Thomas Holz]] <vhskids@gmx.de>}}
{{howto|Advanced|[[Thomas Holz]] <vhskids@gmx.de>}}


Modifiers allow you to modify nodes on before they are used. To add functions like preUpdate use atkTriggerListener
Modifiers allow you to modify nodes on before they are used. To add [[trigger|functions like preUpdate]] like preUpdate use atkTriggerListener





Revision as of 06:41, 20 August 2009

ATK Howto: Add functions (pre/post/...) to an existing node

Complexity: Advanced
Author: Thomas Holz <vhskids@gmx.de>

List of other Howto's

Modifiers allow you to modify nodes on before they are used. To add functions like preUpdate 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 
 {
    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
  {
  
  function preUpdate( &$record )
  { 
    do some code....
    return true;
  }