1 taxonomy.api.php hook_taxonomy_term_view_alter(&$build)

Alter the results of taxonomy_term_view().

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 taxonomy term content structure has been built.

If the module wishes to act on the rendered HTML of the term rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_taxonomy_term(). See backdrop_render() and theme() documentation respectively for details.

Parameters

$build: A renderable array representing the taxonomy term content.

See also

hook_entity_view_alter()

Related topics

File

core/modules/taxonomy/taxonomy.api.php, line 264
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_term_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 term.
  $build['#post_render'][] = 'my_module_taxonomy_term_post_render';
}