4.6.x node.php hook_load($node)
4.7.x node.php hook_load($node)
5.x node.php hook_load($node)
6.x node.php hook_load($node)
7.x node.api.php hook_load($nodes)

Act on nodes being loaded from the database.

This is a node-type-specific hook, which is invoked only for the node type being affected. See Node API hooks for more information.

Use hook_node_load() to respond to node load of all node types.

This hook is invoked during node loading, which is handled by entity_load(), via classes NodeController and DrupalDefaultEntityController. After the node information is read from the database or the entity cache, hook_load() is invoked on the node's content type module, then field_attach_node_revision() or field_attach_load() is called, then hook_entity_load() is invoked on all implementing modules, and finally hook_node_load() is invoked on all implementing modules.

This hook should only be used to add information that is not in the node or node revisions table, not to replace information that is in these tables (which could interfere with the entity cache). For performance reasons, information for all available nodes should be loaded in a single query where possible.


$nodes: An array of the nodes being loaded, keyed by nid.

For a detailed usage example, see node_example.module.

Related topics

69 functions implement hook_load()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

actions_load in includes/actions.inc
Retrieves a single action from the database.
aggregator_category_load in modules/aggregator/aggregator.module
Loads an aggregator category.
aggregator_feed_items_load in modules/aggregator/aggregator.pages.inc
Loads and optionally filters feed items.
aggregator_feed_load in modules/aggregator/aggregator.module
Loads an aggregator feed.
batch_load in includes/batch.inc
Loads a batch from the database.

... See full list

2 invocations of hook_load()
field_attach_load in modules/field/field.attach.inc
Loads fields for the current revisions of a group of entities.
node_preview in modules/node/node.pages.inc
Generates a node preview.


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


function hook_load($nodes) {
  $result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN (:nids)', array(
    ':nids' => array_keys($nodes),
  foreach ($result as $record) {
    $nodes[$record->nid]->foo = $record->foo;


disturbedmime’s picture

$nodes is actually a reference to an array of nodes, and should be modified directly. No return value is necessary for this function.

EDIT: Response to a bug report by jhodgdon, who put this much more concisely than I could muster:

"The doc is correct. $nodes is an array of objects. In PHP all objects are references, and we do NOT document standard PHP syntax/behavior in our Drupal API docs. The function cannot have &$nodes in the signature, because it shouldn't allow you to add/remove items from the array, which is what that would do."