You are here

function views_rss_views_feed_argument in Views (for Drupal 7) 5

feed argument hook that will convert us to RSS or display an icon. the 4th argument isn't part of the hook, but we use it to differentiate when called as a hook or when called manually from views_rss_views_post_view

2 calls to views_rss_views_feed_argument()
views_handler_arg_rss_feed in ./views_rss.module
handler for our own RSS argument; mimics the feed selector
views_rss_views_post_view in ./views_rss.module
post view for our own op -- mimics the feed selector

File

./views_rss.module, line 72

Code

function views_rss_views_feed_argument($op, &$view, $arg, $argdata = NULL) {
  if ($op == 'argument' && $arg == 'feed') {
    $view->page_type = 'views_rss';
    if ($argdata['options']) {
      $view->description = $argdata['options'];
    }

    // reset the 'real url' to the URL without the feed argument.
    $view_args = array();
    $max = count($view->args);
    foreach ($view->args as $id => $view_arg) {
      ++$count;
      if ($view_arg == $arg && $view->argument[$id]['id'] == $argdata['id']) {
        if ($count != $max) {
          $view_args[] = $argdata['wildcard'];
        }
      }
      else {
        $view_args[] = $view_arg;
      }
    }
    $view->feed_url = views_get_url($view, $view_args);
  }
  else {
    if ($op == 'post_view' && $view->build_type != 'block') {
      $args = views_post_view_make_args($view, $arg, 'feed');
      $url = views_get_url($view, $args);
      $title = views_get_title($view, 'page', $args);
      if ($view->used_filters) {
        $filters = drupal_query_string_encode($view->used_filters);
      }
      drupal_add_feed(url($url, $filters), $title);
    }
  }
}