You are here

function views_rss_plugin_style_fields::attach_to in Views RSS 7.2

Same name and namespace in other branches
  1. 6.2 views/views_rss_plugin_style_fields.inc \views_rss_plugin_style_fields::attach_to()

Attach this view to another display as a feed.

File

views/views_rss_plugin_style_fields.inc, line 13
Extends the view_plugin_style class to provide new RSS view style.

Class

views_rss_plugin_style_fields
@file Extends the view_plugin_style class to provide new RSS view style.

Code

function attach_to($display_id, $path, $title) {
  $display = $this->view->display[$display_id]->handler;
  $url_options = array(
    'absolute' => TRUE,
  );
  $input = $this->view
    ->get_exposed_input();
  if ($input) {
    $url_options['query'] = $input;
  }

  // Don't add arguments to RSS path if the feed does not support arguments.
  $feed_path = !empty($this->display->display_options['arguments']) ? $this->view
    ->get_url(NULL, $path) : $path;
  $url = url($feed_path, $url_options);
  if ($display
    ->has_path() && !$this->options['feed_settings']['feed_in_links']) {
    if (empty($this->preview)) {
      drupal_add_feed($url, $title);
    }
  }
  else {
    if (empty($this->view->feed_icon)) {
      $this->view->feed_icon = '';
    }
    $this->view->feed_icon .= theme('feed_icon', array(
      'url' => $url,
      'title' => $title,
    ));
    drupal_add_html_head_link(array(
      'rel' => 'alternate',
      'type' => 'application/rss+xml',
      'title' => $title,
      'href' => $url,
    ));
  }
}