| Versionen | |
|---|---|
| drupal6 | hook_load( |
| drupal7 | hook_load($nodes) |
Load node-type-specific information.
This is a hook used by node modules. It is called to allow the module a chance to load extra information that it stores about a node. The hook should not be used to replace information from the core {node} table since this may interfere with the way nodes are fetched from cache.
$nodes An array of the nodes being loaded, keyed by nid. At call time, node.module has already loaded the basic information about the nodes, such as node ID (nid), title, and body.
For a detailed usage example, see node_example.module.
modules/
<?php
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;
}
}
?>
Kommentare
Kommentar hinzufügen