I am trying to modify $node via hook_node_load but I do not have the current node in the list of $nodes handled by hook_node_load when I check it with devel's dpm. I only have some nodes from a node_load_multiple call I make in the module. Should I use hook_node_view instead? But hook_node_view says it can only modify node content.


It depends on when and where you trying to modify the $node. hook_node_load runs every time a node is loaded,whereas hook_node_view runs only when a node is about to be rendered on the page.

The reason you might not be having the node id in question in you hook_node_load may be because the context in which you are calling hook_node_load might be wrong. In order to test you can create a dummy callback and call the node_load() in it with you nid in question. You can see that once you call the node_load() api, it will invoke a call to hook_node_load.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.