additional_fields['link'] = 'link'; } /** * {@inheritdoc} */ protected function defineOptions() { $options = parent::defineOptions(); $options['display_as_link'] = array('default' => TRUE); return $options; } /** * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', '#default_value' => !empty($this->options['display_as_link']), ); parent::buildOptionsForm($form, $form_state); } /** * {@inheritdoc} */ public function render(ResultRow $values) { $value = $this->getValue($values); return $this->renderLink($this->sanitizeValue($value), $values); } /** * Renders aggregator item's title as link. * * @param string $data * The XSS safe string for the link text. * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * * @return string * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { $link = $this->getValue($values, 'link'); if (!empty($this->options['display_as_link'])) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = $link; $this->options['alter']['html'] = TRUE; $this->options['alter']['absolute'] = TRUE; } return $data; } }