You are here

function NodeTranslationLink::render_link in Views (for Drupal 7) 8.3

1 call to NodeTranslationLink::render_link()
NodeTranslationLink::render in lib/Views/translation/Plugin/views/field/NodeTranslationLink.php
Render the field.

File

lib/Views/translation/Plugin/views/field/NodeTranslationLink.php, line 48
Definition of Views\translation\Plugin\views\field\NodeTranslationLink.

Class

NodeTranslationLink
Field handler to present a link to the node.

Namespace

Views\translation\Plugin\views\field

Code

function render_link($data, $values) {
  $language_interface = language(LANGUAGE_TYPE_INTERFACE);
  $tnid = $this
    ->get_value($values, 'tnid');

  // Only load translations if the node isn't in the current language.
  if ($this
    ->get_value($values, 'langcode') != $language_interface->langcode) {
    $translations = translation_node_get_translations($tnid);
    if (isset($translations[$language_interface->langcode])) {
      $values->{$this->aliases['nid']} = $translations[$language_interface->langcode]->nid;
      $values->{$this->aliases['title']} = $translations[$language_interface->langcode]->title;
    }
  }
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = "node/" . $this
    ->get_value($values, 'nid');
  return $this
    ->get_value($values, 'title');
}