function hook_profile2_view_alter in Profile 2 7
Same name and namespace in other branches
- 7.2 profile2.api.php \hook_profile2_view_alter()
Alter the results of entity_view() for profiles.
Parameters
$build: A renderable array representing the profile content.
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 profile content structure has been built.
If the module wishes to act on the rendered HTML of the profile rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_profile2(). See drupal_render() and theme() documentation respectively for details.
See also
File
- ./
profile2.api.php, line 141 - This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.
Code
function hook_profile2_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';
}
}