Modifying Nodes of Our Type with hookload

The last node-related hook you need for your basic joke module is the ability to add your custom node attributes into the node object as it's constructed. We need to inject the punchline into the node loading process so it's available to other modules and the theme layer. For that you use hook_load().

This hook is called just after the core node object has been built, and is only called for the current node type being loaded. If the node type is joke, then joke_load() is called.

* Implementation of hook_load().

function joke_load($node) { return db_fetch_object(db_query('SELECT punchline FROM {joke} WHERE vid = %d', $node->vid));

0 0

Post a comment

  • Receive news updates via email from this site