node_example_nodeapi

Definition

node_example_nodeapi(&$node, $op, $teaser, $page)
developer/examples/node_example.module, line 207

Description

Implementation of hook_nodeapi().

When a node revision is deleted, we need to remove the corresponding record from our table. The only way to handle revision deletion is by implementing hook_nodeapi().

Code

<?php
function node_example_nodeapi(&$node, $op, $teaser, $page) {
  switch ($op) {
    case 'delete revision':
      // Notice that we're matching a single revision based on the node's vid.
      db_query('DELETE FROM {node_example} WHERE vid = %d', $node->vid);
      break;
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.