function template_preprocess_taxonomy_term
template_preprocess_taxonomy_term(&$variables)
Process variables for taxonomy-term.tpl.php.
File
- modules/taxonomy/taxonomy.module, line 909
- Enables the organization of content into categories.
Code
function template_preprocess_taxonomy_term(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; $variables['term'] = $variables['elements']['#term']; $term = $variables['term']; $uri = entity_uri('taxonomy_term', $term); $variables['term_url'] = url($uri['path'], $uri['options']); $variables['term_name'] = check_plain($term->name); $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term); // Flatten the term object's member fields. $variables = array_merge((array) $term, $variables); // Helpful $content variable for templates. $variables['content'] = array(); foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } // field_attach_preprocess() overwrites the $[field_name] variables with the // values of the field in the language that was selected for display, instead // of the raw values in $term->[field_name], which contain all values in all // languages. field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables); // Gather classes, and clean up name so there are no underscores. $vocabulary_name_css = str_replace('_', '-', $term->vocabulary_machine_name); $variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css; $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->vocabulary_machine_name; $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term->tid; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/template_preprocess_taxonomy_term/7.x