Using custom action handlers

From Achievo/ATK Wiki

Jump to: navigation, search

ATK Howto: Using custom action handlers

Complexity: Advanced
Author: Rene Bakx <rene@nospamformeplease.71media.net>

List of other Howto's

Using the atkActionHandler to extend a handler

Note: This page uses features that require version 6.5 or higher.

Every action, like export, add, delete etc, within a node can be extended to use your own action. In this case we use it to change the behaviour of the export action.

Use case: you want the behaviour of the export action in ATK, but you want to tweak it slightly.

Adding a handler to your node

At the top of your node file, add the following lines:

// Import the class definition of myExportHandler
atkimport("mymodule.myExportHandler");
 
// Register the export handler class 
atkRegisterNodeHandler('myNode', 'export', new myExportHandler());

Where the mymodule is ofcourse your module folder, the myExportHandler the name of your handler.

The atkRegisterNodeHandler also takes a * as first parameter to match all the nodes in the scope, if you hook the node handler in your own extended atkNode for example.

The myExportHandler class is an extended atkActionHandler where some of the functions where overloaded, but the third parameter can also be a static method with two parameters (see atknode.Callhandler method).

Writing a custom handler

A sample myExportHandler class could look like this:

class myExportHandler extends atkExportHandler // extend the default exporting functionality
{
  public function ..... // override whichever function you want to change
}

For an overview of default available (and thus extendable) actionHandlers see the handlers folder in your atk directory.

Personal tools
Navigation