function views_handler_field_taxonomy::render_link

Same name in other branches
  1. 6.x-3.x modules/taxonomy/views_handler_field_taxonomy.inc \views_handler_field_taxonomy::render_link()

Render whatever the data is as a link to the taxonomy.

Data should be made XSS safe prior to calling this function.

1 call to views_handler_field_taxonomy::render_link()
views_handler_field_taxonomy::render in modules/taxonomy/views_handler_field_taxonomy.inc
Render the field.

File

modules/taxonomy/views_handler_field_taxonomy.inc, line 67

Class

views_handler_field_taxonomy
Field handler to provide simple renderer that allows linking to a taxonomy term.

Code

public function render_link($data, $values) {
    $tid = $this->get_value($values, 'tid');
    if (!empty($this->options['link_to_taxonomy']) && !empty($tid) && $data !== NULL && $data !== '') {
        $term = new stdClass();
        $term->tid = $tid;
        $term->vid = $this->get_value($values, 'vid');
        $term->name = $this->get_value($values, 'name');
        $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']};
        $this->options['alter']['make_link'] = TRUE;
        $uri = entity_uri('taxonomy_term', $term);
        if (isset($uri['options'])) {
            $this->options['alter'] = array_merge($this->options['alter'], $uri['options']);
        }
        $this->options['alter']['path'] = $uri['path'];
        // If entity_uri() returned an options array, use it.
        if (isset($uri['options'])) {
            $this->options['alter'] = $uri['options'] + $this->options['alter'];
        }
    }
    if (!empty($this->options['convert_spaces'])) {
        $data = str_replace(' ', '-', $data);
    }
    return $data;
}