| 7 node.api.php | hook_node_prepare($node) |
| 8 node.api.php | hook_node_prepare(Drupal node Node $node) |
Act on a node object about to be shown on the add/edit form.
This hook is invoked from node_object_prepare() after the type-specific hook_prepare() is invoked.
Parameters
$node: The node that is about to be shown on the add/edit form.
Related topics
4 functions implement hook_node_prepare()
1 invocation of hook_node_prepare()
File
- modules/
node/ node.api.php, line 633 - Hooks provided by the Node module.
Code
function hook_node_prepare($node) {
if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
}
}
Login or register to post comments
Comments
Issue
I click in the edit link but the function not called ? i need help !
Clear cache and try again
Clear cache and try again
no variable by reference?
How come the $node variable isn't a reference here (as opposed to D6)?
$node is an object, so its
$nodeis an object, so its properties are 'by reference' automatically.The only difference: overwriting the entire node object with another object is not possible anymore. You shouldn't do that anyway.