From 6445ba5986760d38b1f91a3f8fb1170a480c82c6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 10 May 2009 20:41:17 +0000 Subject: - Patch #367214 by alienbrain: added documentation for hook_node_build_alter and remove documentatin for hook_node_alter. --- modules/node/node.api.php | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'modules/node/node.api.php') diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 6b052aa5d..98f31627d 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -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. * -- cgit v1.2.3