You are here

function panelizer_handler_field_link::render_link in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 plugins/views/panelizer_handler_field_link.inc \panelizer_handler_field_link::render_link()

Overrides views_handler_field_node_link::render_link

File

plugins/views/panelizer_handler_field_link.inc, line 41

Class

panelizer_handler_field_link
Views field handler for rendering node links that point to panelizer tabs.

Code

function render_link($entity, $values) {
  if (!$entity) {
    return;
  }
  $entity_type = $this->definition['entity_type'];
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
  if ($handler && $handler
    ->is_panelized($bundle) && $handler
    ->panelizer_access($this->options['panelizer_tab'], $entity)) {
    $this->options['alter']['make_link'] = TRUE;
    $path = str_replace("%{$entity_type}", $entity_id, $handler->plugin['entity path']) . '/panelizer/' . $this->options['panelizer_tab'];
    $this->options['alter']['path'] = $path;
    $this->options['alter']['query'] = drupal_get_destination();
    $text = !empty($this->options['text']) ? $this->options['text'] : $this->tab_map[$this->options['panelizer_tab']];
    return $text;
  }
}