Last updated February 26, 2011. Created by aufumy on July 13, 2010.
Edited by Fyrsten, benlotter. Log in to edit this page.
Scott Hadfield has an informative tutorial about triggers.
This is a short module, that works with triggers, triggerunlock module, to allow you to assign actions (e.g. send email) upon node revision.
<?php
/**
* Implementation of hook_hook_info().
*/
function my_custom_trigger_hook_info() {
return array(
'my_custom_trigger' => array(
'nodeapi' => array(
'revision' => array(
'runs when' => t('After node revision is created'),
),
),
),
);
}
/**
* Implementation of hook_nodeapi().
*/
function my_custom_trigger_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
// When creating a new revision
if ($op == 'update' && $node->revision == 1) {
$aids = _trigger_get_hook_aids('nodeapi', 'revision');
$context = array(
'hook' => 'nodeapi',
'op' => $op,
'node' => $node,
);
actions_do(array_keys($aids), $node, $context);
}
}
?>
Comments
About this page
Should this be placed under the module creation tutorial? It seems odd that it's here.
http://www.vilepickle.com
Re: About this page
I agree with vilepickle. This page seems out of place.
Robbie Jackson
www.drupalcreations.com
robbiejackson@drupalcreations.com
Skype: beaverleaderdad
Linkedin profile: http://ca.linkedin.com/pub/robbie-jackson/b/a4b/357
At the earliest
At the earliest, it could come after the introduction page describing actions: Writing actions.
And, to be honest, it looks to me like that page is a bit out of place, too.
This page shouldn't be here.
All of a sudden, it now discuss triggers without a proper introduction.