You are here

public function views_handler_field_term_node_tid::add_self_tokens in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 modules/taxonomy/views_handler_field_term_node_tid.inc \views_handler_field_term_node_tid::add_self_tokens()
  2. 6.2 modules/taxonomy/views_handler_field_term_node_tid.inc \views_handler_field_term_node_tid::add_self_tokens()

Add any special tokens this field might use for itself.

This method is intended to be overridden by items that generate fields as a list. For example, the field that displays all terms on a node might have tokens for the tid and the term.

By convention, tokens should follow the format of [token-subtoken] where token is the field ID and subtoken is the field. If the field ID is terms, then the tokens might be [terms-tid] and [terms-name].

Overrides views_handler_field::add_self_tokens

File

modules/taxonomy/views_handler_field_term_node_tid.inc, line 158
Definition of views_handler_field_term_node_tid.

Class

views_handler_field_term_node_tid
Field handler to display all taxonomy terms of a node.

Code

public function add_self_tokens(&$tokens, $item) {
  foreach (array(
    'tid',
    'name',
    'vocabulary_machine_name',
    'vocabulary',
  ) as $token) {

    // Replace _ with - for the vocabulary machine name.
    $tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token) . ']'] = isset($item[$token]) ? $item[$token] : '';
  }
}