Same name and namespace in other branches
  1. 4.7.x developer/examples/node_example.module \node_example_nodeapi()

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().

File

developer/examples/node_example.module, line 185
This is an example outlining how a module can be used to define a new node type.

Code

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;
  }
}