| 5 node.php | hook_load($node) |
| 6 node.php | hook_load( |
| 7 node.api.php | hook_load($nodes) |
| 8 node.api.php | 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, or possibly replace already loaded information - which can be dangerous.
Parameters
$node: The node being loaded. At call time, node.module has already loaded the basic information about the node, such as its node ID (nid), title, and body.
Return value
An object containing properties of the node being loaded. This will be merged with the passed-in $node to result in an object containing a set of properties resulting from adding the extra properties to the passed-in ones, and overwriting the passed-in ones with the extra properties if they have the same name as passed-in properties.
For a detailed usage example, see node_example.module.
Related topics
File
- developer/
hooks/ node.php, line 320 - These hooks are defined by node modules, modules that define a new kind of node.
Code
<?php
function hook_load($node) {
$additions = db_fetch_object(db_query('SELECT * FROM {mytable} WHERE vid = %d', $node->vid));
return $additions;
}
?> Login or register to post comments
Comments
object merge
I experienced a problem with calling this function from a non-hook because I expected the returned object to contain all the properties of the node, and whatever else gets loaded in hook_load. Instead, as the API is worded, this function should only return new properties specific to your content module's node type. You may have to merge the $node and the object containing all your new properties returned by hook_load, to work with a complete node object.
use node_load?
@beefzilla - doesn't "node_load($nid)" do the merging for you?
Probably better to call node_load because that way you get extras from all the modules you've got installed?
Could be I'm not fully understanding the issue though! :-)