Node API Hooks

Functions to define and modify content types.

Each content type is maintained by a primary module, which is either node.module (for content types created in the user interface) or the module that implements hook_node_info() to define the content type.

During node operations (create, update, view, delete, etc.), there are several sets of hooks that get invoked to allow modules to modify the base node operation:

  • Node-type-specific hooks: These hooks are only invoked on the primary module, using the "base" return component of hook_node_info() as the function prefix. For example, poll.module defines the base for the Poll content type as "poll", so during creation of a poll node, hook_insert() is only invoked by calling poll_insert().
  • All-module hooks: This set of hooks is invoked on all implementing modules, to allow other modules to modify what the primary node module is doing. For example, hook_node_insert() is invoked on all modules when creating a poll node.
  • Field hooks: Hooks related to the fields attached to the node. These are invoked from the field operations functions described below, and can be either field-type-specific or all-module hooks.
  • Entity hooks: Generic hooks for "entity" operations. These are always invoked on all modules.

Here is a list of the node and entity hooks that are invoked, field operations, and other steps that take place during node operations:

Functions & methods

NameLocationDescription
hook_deletemodules/node/node.api.phpRespond to node deletion.
hook_formmodules/node/node.api.phpDisplay a node editing form.
hook_insertmodules/node/node.api.phpRespond to creation of a new node.
hook_loadmodules/node/node.api.phpAct on nodes being loaded from the database.
hook_node_deletemodules/node/node.api.phpRespond to node deletion.
hook_node_infomodules/node/node.api.phpDefine module-provided node types.
hook_node_insertmodules/node/node.api.phpRespond to creation of a new node.
hook_node_loadmodules/node/node.api.phpAct on nodes being loaded from the database.
hook_node_preparemodules/node/node.api.phpAct on a node object about to be shown on the add/edit form.
hook_node_presavemodules/node/node.api.phpAct on a node being inserted or updated.
hook_node_revision_deletemodules/node/node.api.phpRespond to deletion of a node revision.
hook_node_search_resultmodules/node/node.api.phpAct on a node being displayed as a search result.
hook_node_submitmodules/node/node.api.phpAct on a node after validated form values have been copied to it.
hook_node_updatemodules/node/node.api.phpRespond to updates to a node.
hook_node_update_indexmodules/node/node.api.phpAct on a node being indexed for searching.
hook_node_validatemodules/node/node.api.phpPerform node validation before a node is created or updated.
hook_node_viewmodules/node/node.api.phpAct on a node that is being assembled before rendering.
hook_node_view_altermodules/node/node.api.phpAlter the results of node_view().
hook_preparemodules/node/node.api.phpAct on a node object about to be shown on the add/edit form.
hook_rankingmodules/node/node.api.phpProvide additional methods of scoring for core search results for nodes.
hook_updatemodules/node/node.api.phpRespond to updates to a node.
hook_validatemodules/node/node.api.phpPerform node validation before a node is created or updated.
hook_viewmodules/node/node.api.phpDisplay a node.

File

modules/node/node.api.php, line 8
Hooks provided by the Node module.