hook_load
- Versions
- 4.6 – 6
hook_load($node)- 7
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.
For a detailed usage example, see node_example.module.
Parameters
$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.
Related topics
Code
modules/node/node.api.php, line 904
<?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;
}
}
?>Login or register to post comments 