You are here

class feedapi_handler_field_url in FeedAPI 6

Field handler to provide title links to drupal nodes

Hierarchy

Expanded class hierarchy of feedapi_handler_field_url

2 string references to 'feedapi_handler_field_url'
feedapi_node_views_data in feedapi_node/views/feedapi_node.views.inc
Implementation of hook_views_data().
feedapi_views_data in views/feedapi.views.inc
Implementation of hook_views_data().

File

views/handlers/feedapi_handler_field_url.inc, line 8

View source
class feedapi_handler_field_url extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();
    $options['display_url'] = array(
      'default' => 'url',
    );
    return $options;
  }
  function query() {
    if ($this->options['display_url'] == 'title') {
      $this->additional_fields['title'] = array(
        'table' => 'node',
        'field' => 'title',
      );
    }
    parent::query();
  }

  /**
   * Provide link to the page being visited.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['display_url'] = array(
      '#title' => t('Display'),
      '#type' => 'select',
      '#options' => array(
        'title' => t("Node title as link"),
        'url' => t('URL as link'),
        'text' => t('URL as plain text'),
      ),
      '#default_value' => $this->options['display_url'],
    );
  }
  function render($values) {
    $value = $values->{$this->field_alias};
    if ($this->options['display_url'] == 'title') {
      return l($values->{$this->aliases['title']}, $value);
    }
    if ($this->options['display_url'] == 'url') {
      return l($value, $value);
    }
    return $value;
  }

}

Members