1.20.x taxonomy.module taxonomy_term_view(TaxonomyTerm $term, $view_mode = 'full', $langcode = NULL)

Generate an array for rendering the given term.

Parameters

TaxonomyTerm $term: A taxonomy term entity.

$view_mode: (optional) Display mode, e.g. 'full' or 'teaser'. Defaults to 'full'.

$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Return value

An array as expected by backdrop_render().:

File

modules/taxonomy/taxonomy.module, line 863
Enables the organization of content into categories.

Code

function taxonomy_term_view(TaxonomyTerm $term, $view_mode = 'full', $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->langcode;
  }

  // Populate $term->content with a render() array.
  taxonomy_term_build_content($term, $view_mode, $langcode);
  $build = $term->content;

  // We don't need duplicate rendering info in $term->content.
  unset($term->content);

  $build += array(
    '#theme' => 'taxonomy_term__' . $term->vocabulary . '__' . $view_mode,
    '#term' => $term,
    '#view_mode' => $view_mode,
    '#language' => $langcode,
  );

  $build['#attached']['css'][] = backdrop_get_path('module', 'taxonomy') . '/css/taxonomy.css';

  // Allow modules to modify the structured taxonomy term.
  $type = 'taxonomy_term';
  backdrop_alter(array('taxonomy_term_view', 'entity_view'), $build, $type);

  return $build;
}