hook_node_load

  1. drupal
    1. drupal7
Versionen
drupal7 hook_node_load($nodes, $types)

Act on node objects when loaded.

This hook allows you to add information to node objects when loaded from the database. It takes an array of nodes indexed by nid as its first parameter. For performance reasons, information for all available nodes should be loaded in a single query where possible.

The types of all nodes being passed in are also available in the $types parameter. If your module keeps track of the node types it supports, this allows for an early return if nothing needs to be done.

Due to the internal cache in node_load_multiple(), you should not use this hook to modify information returned from the {node} table itself, since this may affect the way nodes are returned from the cache in subsequent calls to the function.

Übergabeparameter

$nodes An array of node objects indexed by nid.

$types An array containing the types of the nodes.

See also

comment_node_load()

taxonomy_node_load()

forum_node_load()

Verwandte Themen

Code

modules/node/node.api.php, line 343

<?php
function hook_node_load($nodes, $types) {
  $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;
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen