taxonomy_term_view

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL)

Generate an array for rendering the given term.

Parameters

$term A term object.

$view_mode View mode, e.g. 'full', 'teaser'...

$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 drupal_render().

▾ 1 function calls taxonomy_term_view()

taxonomy_term_page in modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.

Code

modules/taxonomy/taxonomy.module, line 725

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

  field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode, $langcode);
  entity_prepare_view('taxonomy_term', array($term->tid => $term), $langcode);

  $build = array(
    '#theme' => 'taxonomy_term', 
    '#term' => $term, 
    '#view_mode' => $view_mode, 
    '#language' => $langcode,
  );

  $build += field_attach_view('taxonomy_term', $term, $view_mode, $langcode);

  // Add term description if the term has one.
  if (!empty($term->description)) {
    $build['description'] = array(
      '#markup' => check_markup($term->description, $term->format, '', TRUE), 
      '#weight' => 0, 
      '#prefix' => '<div class="taxonomy-term-description">', 
      '#suffix' => '</div>',
    );
  }

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

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

  return $build;
}
?>