Hi,

I have a view with 2 page displays (blog, and blog/) and 1 feed display (feed/blog). I am attaching the feed to both the displays.

The page_2 display (blog/) accepts a contextual filter for year, and will show a list of blogs filtered by the given year.

The rss icon for page_1 (blog) links to 'feed/blog', which is correct. The rss icon for page_2 (blog/2011), however, shows 'feed/blog/2011', which is incorrect, as my feed does not have a contextual filter.

Though the feed on feed/blog/2011 does show the same content as feed/blog, for SEO purposes, they should ideally use the same url if they have the same content.

I have created a patch to take into account whether the feed display supports arguments, and if it does, the arguments will be added to the path (as it currently does), if not, the arguments will be excluded from the path.

Hope this helps.

Cheers,
Victoria

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

victoriachan’s picture

Attaching patch. It is only a few lines:


class views_plugin_style_rss extends views_plugin_style {
  function attach_to($display_id, $path, $title) {
// ...

// Don't add arguments to RSS path if the feed does not support arguments
$feed_path = $this->display->display_options['arguments'] ? $this->view->get_url(NULL, $path) : $path;
$url = url($feed_path, $url_options);

//...
dawehner’s picture

Status: Needs review » Needs work
+++ plugins/views_plugin_style_rss.incundefined
@@ -14,12 +14,16 @@ class views_plugin_style_rss extends views_plugin_style {
+    $feed_path = $this->display->display_options['arguments'] ? $this->view->get_url(NULL, $path) : $path;

It's probably better to use either $view->argument or $view->get_items because $this->display->display_options might have problems with overriden values etc.

jamix’s picture

#1 works great here, thanks.

@dawehner: $this->view seems to be holding the object for the display the feed is being attached to, which makes relying on $this->view->argument not work.

jamix’s picture

Re-rolling patch from #1 to fix PHP notice when there are no contextual filters defined in the view at all.

jamix’s picture

Attaching the correct patch file for #4.

MKorostoff’s picture

Thanks

ygerasimov’s picture

Version: 7.x-3.0-rc1 » 7.x-3.x-dev
Status: Needs work » Needs review
FileSize
734 bytes

Rerolled #5 patch without trailing spaces.

jos_s’s picture

Issue summary: View changes

#7 worked for me. Would be nice if this patch could now be included in Views. Or is anything stopping this?

Anonymous’s picture

#7 worked for me well, using Views 7.x-3.13 and Drupal 7.42.

This patch is really useful - nobody wants people to subscribe to a feed with last year's blog entries, news etc. Like jos_s (#8) I'd be very happy to see the patch included in Views.

ron_s’s picture

Traditionally, Views RSS and Date iCal feeds work by inheriting the contextual filters from the Views displays to which they are attached. There may not be any filters on existing feeds, and patch #7 will break feeds that have paths such as "/calendar/%/rss.xml" and no filter.

Something needs to be included in the patch to notify developers that existing feeds may stop working. There also needs to be coordination with patches for Views RSS (https://www.drupal.org/node/1722348) and Date iCal (https://www.drupal.org/node/2791847).

As well, I understand the issue being recognized, but have the implications of no longer inheriting contextual filters for feeds been fully thought through? Thanks.

riddhi.addweb’s picture

Issue tags: +rss feeds, +contextual filter