Contributions API

node_example_nodeapi

Definition

node_example_nodeapi(&$node, $op, $teaser, $page)
documentation/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;
  }
}
?>