I'm trying to implement actions - trigger support in my module (not standard NODE / USER / TAXONOMY actions, but my custom ones). Can anyone point me to some documentation which describes this in details, or perhaps give me a hand with this problem. Thanks in advance.

I understand that

hook_hook_info()

is responsible for letting the engine know about available actions, and I assume that

hook_action_info()

is responsible for providing triggers, but there is no info about this hook in api doc.

sorry for my English.

Comments

I' ve found some more info, but I still need help...

here is the description for hook_action_info

http://drupal.org/files/issues/hook_action_info_d6.patch

----------------------------------------
Boldizsár Bednárik ing.
http://www.bboldi.com

----------------------------------------
Boldizsár Bednárik ing.

http://notifier.b2labs.com | http://oglasisrbije.com | http://onlineszotar.com | http://b2hq.com

Creating Actions is fairly

Creating Actions is fairly straight forward and works as documented here:
http://drupal.org/node/172152

Creating triggers is definitely possible, but not very well documented, and I'd recommend looking at the simplest of the existing trigger implementations - maybe node.module...

You may find some triggers help in this talk...
http://www.archive.org/details/DrupalconBoston2008-TriggersAndActionsAnd...

Later,
Chris.

http://www.trailheadinteractive.com

thanks

Thanks man!

----------------------------------------
Boldizsár Bednárik ing.
http://www.bboldi.com

----------------------------------------
Boldizsár Bednárik ing.

http://notifier.b2labs.com | http://oglasisrbije.com | http://onlineszotar.com | http://b2hq.com

Here is a sample module code I wrote to demonstrate the method for defining new actions and triggers and join them together. I hope it will help the community ;)

This code will add a new tab to the trigger page named "action trigger sample", it's simple and understundable... i hope...

<?php
/**
* @author Bednarik Boldizsar
* @copyright 2008
*/

function atsample_init()
{
   
// fire the trigger
   
   
_atsample_invoke_every_page_trigger();
   
_atsample_invoke_random_page_trigger();
}

function
_atsample_invoke_every_page_trigger()
{
   
$aids = _trigger_get_hook_aids('atsample', 'on_every_page');
   
    foreach (
$aids as $aid => $action_info) {
       
       
$message = 'EVERY PAGE Hello World!';
       
actions_do($aid,$message);
    }

}

function
_atsample_invoke_random_page_trigger()
{
    function
make_seed()
    {
      list(
$usec, $sec) = explode(' ', microtime());
      return (float)
$sec + ((float) $usec * 100000);
    }

   
srand(make_seed());
   
$randval = rand();
   
    if((
$randval % 3) == 0)
    {   
        
$aids = _trigger_get_hook_aids('atsample', 'on_random_page');
         
          foreach (
$aids as $aid => $action_info) {
           
$message = 'RANDOM Hello World!';
             
actions_do($aid,$message);
        }
    }
}

function
atsample_hook_info() {
  return array(
   
'atsample' => array(
     
'atsample' => array(
       
'on_every_page' => array(
         
'runs when' => t('On every page'),
        ),
       
'on_random_page' => array(
         
'runs when' => t('On random pages'),
        ),
      ),
    ),
  );
}

/**
* Implementation of hook_action_info().
*/
function atsample_action_info() {
  return array(
   
'atsample_show_message' => array(
     
'description' => t('Show a Hello World message!'),
     
'type' => 'atsample',
     
'configurable' => false,
     
'hooks' => array(
       
'atsample' => array('on_every_page', 'on_random_page'),
      )
    ),
  );
}

/**
* The action callback function
*/

function atsample_show_message(&$object,$context)
{
   
drupal_set_message($object);
}
?>

----------------------------------------
Boldizsár Bednárik ing.
http://www.bboldi.com

----------------------------------------
Boldizsár Bednárik ing.

http://notifier.b2labs.com | http://oglasisrbije.com | http://onlineszotar.com | http://b2hq.com

HI, where should this code

HI, where should this code be placed?

In a custom module, or in actions.inc or somewhere else entirely?

Thanks
Dave

"Set a man a flame, keep him warm for a day. Set a man aflame, keep him warm for the rest of his life."

it's a sample custom module.

it's a sample custom module.

----------------------------------------
Boldizsár Bednárik ing.

http://notifier.b2labs.com | http://oglasisrbije.com | http://onlineszotar.com | http://b2hq.com

Wow, just reread this - you'd

Wow, just reread this - you'd think I would've copped that from where you said "Here is a sample module code I wrote"! Cheers man, sorry for the silly question!

Dave

"Set a man a flame, keep him warm for a day. Set a man aflame, keep him warm for the rest of his life."

nobody click here