| 1 |
<?php |
<?php |
| 2 |
// $Id: node.api.php,v 1.41 2009/10/24 11:49:52 dries Exp $ |
// $Id: node.api.php,v 1.42 2009/11/01 12:11:10 dries Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 540 |
} |
} |
| 541 |
|
|
| 542 |
/** |
/** |
| 543 |
* The node content was built, the module may modify the structured content. |
* The node content was built; the module may modify the structured content. |
| 544 |
* |
* |
| 545 |
* This hook is called after the content has been assembled in $node->content |
* This hook is called after the content has been assembled in a structured array |
| 546 |
* and may be used for doing processing which requires that the complete node |
* and may be used for doing processing which requires that the complete node |
| 547 |
* content structure has been built. |
* content structure has been built. |
| 548 |
* |
* |
| 551 |
* Alternatively, it could also implement hook_preprocess_node(). See |
* Alternatively, it could also implement hook_preprocess_node(). See |
| 552 |
* drupal_render() and theme() documentation respectively for details. |
* drupal_render() and theme() documentation respectively for details. |
| 553 |
* |
* |
| 554 |
* @param $node |
* @param $build |
| 555 |
* The node the action is being performed on. |
* A renderable array representing the node content. |
| 556 |
* @param $build_mode |
* |
| 557 |
* The $build_mode parameter from node_build(). |
* @see node_build() |
| 558 |
*/ |
*/ |
| 559 |
function hook_node_build_alter(stdClass $node, $build_mode) { |
function hook_node_build_alter($build) { |
| 560 |
// Check for the existence of a field added by another module. |
if ($build['#build_mode'] == 'full' && isset($build['an_additional_field'])) { |
|
if (isset($node->content['an_additional_field'])) { |
|
| 561 |
// Change its weight. |
// Change its weight. |
| 562 |
$node->content['an_additional_field']['#weight'] = -10; |
$build['an_additional_field']['#weight'] = -10; |
| 563 |
} |
} |
| 564 |
|
|
| 565 |
// Add a #post_render callback to act on the rendered HTML of the node. |
// Add a #post_render callback to act on the rendered HTML of the node. |
| 566 |
$node->content['#post_render'][] = 'my_module_node_post_render'; |
$build['#post_render'][] = 'my_module_node_post_render'; |
| 567 |
} |
} |
| 568 |
|
|
| 569 |
/** |
/** |