Rules event: node edit

Public

Rules is a powerfull module which allow developer or site administrator to fast and easy configure behaviors. Creating events and actions is often simpler than using hooks.
But, by default there is no event triggered when user enter to the node edit form, so i wrote my own implementation in custom module called 'coolmodule':

coolmodule.rules.inc

</> CopyGet raw version
php
  1. /**
  2.  * Implementation of hook_rules_event_info().
  3.  */
  4. function coolmodule_rules_event_info() {
  5. $events = array();
  6.  
  7. $events['coolmodule_rules_edit'] = array(
  8. 'label' => t('Trying to edit a Node'),
  9. 'group' => t('Node'),
  10. 'variables' => array(
  11. 'node' => array(
  12. 'type' => 'node',
  13. 'label' => t('Node to edit')
  14. ),
  15. )
  16. );
  17.  
  18. return $events;
  19.  
  20. }

coolmodule.module

</> CopyGet raw version
php
  1. /**
  2.  * Implements hook_node_prepare
  3.  */
  4. function coolmodule_node_prepare($node) {
  5. //Invoke custom rules event
  6. rules_invoke_event('coolmodule_rules_edit', $node);
  7. }

Comments

Baltazar's picture

You made my day dude. Awsome hook! so many thanks!