Skip to content
Snippets Groups Projects
Commit 6445ba59 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #367214 by alienbrain: added documentation for hook_node_build_alter...

- Patch #367214 by alienbrain: added documentation for hook_node_build_alter and remove documentatin for hook_node_alter.
parent 188b2308
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -154,24 +154,6 @@ function hook_node_operations() {
return $operations;
}
/**
* Fiter, substitute or otherwise alter the $node's raw text.
*
* The $node->content array has been rendered, so the node body or
* teaser is filtered and now contains HTML. This hook should only be
* used when text substitution, filtering, or other raw text operations
* are necessary.
*
* @param $node
* The node the action is being performed on.
* @param $teaser
* The $teaser parameter from node_view().
* @return
* None.
*/
function hook_node_alter($node, $teaser) {
}
/**
* Act on node deletion.
*
......@@ -407,6 +389,34 @@ function hook_node_view($node, $teaser) {
);
}
/**
* The node content was built, the module may modify the structured content.
*
* This hook is called after the content has been assembled in $node->content
* and may be used for doing processing which requires that the complete node
* content structure has been built.
*
* If the module wishes to act on the rendered HTML of the node rather than the
* structured content array, it may use this hook to add a #post_render callback.
* Alternatively, it could also implement hook_preprocess_node(). See
* drupal_render() and theme() documentation respectively for details.
*
* @param $node
* The node the action is being performed on.
* @param $teaser
* The $teaser parameter from node_build().
*/
function hook_node_build_alter($node, $teaser) {
// Check for the existence of a field added by another module.
if (isset($node->content['an_additional_field'])) {
// Change its weight.
$node->content['an_additional_field']['#weight'] = -10;
);
// Add a #post_render callback to act on the rendered HTML of the node.
$node->content['#post_render'][] = 'my_module_node_post_render';
}
/**
* Define module-provided node types.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment