You are here

function hook_field_collection_item_view_alter in Field collection 7

Alter the results of entity_view() for field collection items.

This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete field collection item content structure has been built.

If the module wishes to act on the rendered HTML of the field collection item rather than the structured content array, it may use this hook to add a #post_render callback. See drupal_render() and theme() documentation respectively for details.

Parameters

$build: A renderable array representing the field collection item content.

See also

hook_entity_view_alter()

File

./field_collection.api.php, line 174
Contains API documentation and examples for the Field Collection.

Code

function hook_field_collection_item_view_alter($build) {
  if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {

    // Change its weight.
    $build['an_additional_field']['#weight'] = -10;

    // Add a #post_render callback to act on the rendered HTML of the entity.
    $build['#post_render'][] = 'my_module_post_render';
  }
}