| Version 1 (modified by peter, 3 years ago) |
|---|
/**
* Respond to node deletion.
*
* This hook is invoked from node_delete_multiple() after the node has been
* removed from the node table in the database, after the type-specific
* hook_delete() has been invoked, and before field_attach_delete() is called.
*
* @param $node
* The node that is being deleted.
*
* @ingroup node_api_hooks
* @ingroup hooks
*/
function hook_node_delete($node) {
db_delete('mytable')
->condition('nid', $node->nid)
->execute();
}
The documentation for a hook definition follows the same guidelines as for regular functions (see above), except that the first line is a verb in the imperative form, e.g. "Respond to xyz". Also, a sample function body is provided, usually from a core module's implementation of the hook. It is also helpful to mention somewhere in the documentation where the hook is invoked.
