I have an oddly simple question. Is it possible to prevent RSS feeds from being published in Drupal 7?

[Edited for clarity]

Comments

rschwab’s picture

Disable the Aggregator module?

- Ryan

tgeller’s picture

rschwab writes:

Disable the Aggregator module?

That only affects a site's ability to subscribe to RSS. It doesn't stop it from publishing.

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

sillygwailo’s picture

There's a module called RSS Permissions module that does this for Drupal 6, but not yet 7. It might be a good idea to submit a request there for a Drupal 7 release.

There's also discussion about a feature to disable RSS completely: #748956: Disable RSS completely though again, it's still for D6, and testing/reviewing the feature for 6 will help make it possible for a potential D7 release.

(Username formerly my full name, Richard Eriksson.)

tgeller’s picture

Ah, thanks for the link! Following a link from that module's issue queue brought me to #28337: Add permissions to disable RSS feeds, which was first filed in 2005 and has been put off for D8. Here's to hoping it makes it in!

Any any case, that answers my question: It's not possible in core D6 or D7. Many thanks.

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

sillygwailo’s picture

I made a first go at porting the module to D7: #945462: Port to Drupal 7. Still needs a little bit of work on the Taxonomy feed front, though.

(Username formerly my full name, Richard Eriksson.)

tgeller’s picture

Just a quick note to recognize that the D7 version is now in beta. Thanks!

http://drupal.org/project/rss_permissions

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

CarbonTurtle’s picture

I spent a while looking for a solution to this same issue. I'm using Drupal 7.8, and I derived the following solution from a solution I found here that was tagged for Drupal 4.7.x and 5.x.

Disclaimer: this doesn't stop D7 from publishing the feed, but it strips the RSS link from the using the theme's template.

My theme is derived from Zen. I copied html.tpl.php and page.tpl.php into my theme's templates directory, where they will override the base template's behavior.

Then, I modified html.tpl.ptp by adding two lines just before the template's "print $head;"

<?php
	$rssfeed_replace_regex = '/<link\s+rel="alternate"\s+type="application\/rss\+xml".+?\/rss.xml"\s+\/>/';
	$head = preg_replace($rssfeed_replace_regex,'',$head);
	print $head; ?>

Then, in page.tpl.php I commented out the line that prints the feed icons:
<?php /* print $feed_icons; */ ?>

I think it'd be great if there was a checkbox in the core config where you could enable or disable feeds.

sillygwailo’s picture

I've added this as a feature request to the RSS Permissions module: #1310366: Turn off just the link element and feed icon but keep RSS publishing.

(Username formerly my full name, Richard Eriksson.)

jmanarivo’s picture

I commented out the the 2454th line within the node.module and the function node_page_default(), it's worked !
I'm not an expert but tell me if it's not a good practice!!

/*drupal_add_feed('rss.xml', variable_get('site_name', 'Drupal') . ' ' . t('RSS'));*/
FiNeX’s picture

Hi @jmanarivo, modifying core files is not a good practice, one reason is due to updates: when you will update your Drupal installation you will have to remember to re-apply all the changes you've done.

A better solution is to implement a custom module which override the defaults.

bye!

P.S: http://drupal.org/project/rss_permissions looks quite stable on D7, give it a try.

Cablestein’s picture

I find it ridiculous that RSS is enabled by default.

dblue’s picture

(I agree with everyone else who thinks RSS should be off by default, but that said...) in D7 at least we now have another (perhaps less hacky) way to stop publishing the link in the document head: hook_html_head_alter.

Be sure to notice what commenter malc0mn said over there on the api reference page, "Unlike other hooks, this is a theme hook..."

To get rid of the offending link, we implemented hook_html_head_alter in our theme's template.php to iterate over the head elements and remove the link for the RSS feed; something along these lines:

function MY_THEME_html_head_alter(&$head_elements) {
	$rss_title = check_plain(variable_get('site_name', 'Drupal')) . ' RSS';
	foreach( $head_elements as $key=>$elem ) {
		if( isset($elem['#attributes']['title']) && ($elem['#attributes']['title'] == $rss_title) ) {
			unset( $head_elements[$key] );
			break;
		}
	}
}
kimu’s picture

I've made a change on dblue's solution, because site_name couldn't always be the right value to depend on.
Using a regex and unsetting the entire array seems to be more safe.

function MY_THEME_html_head_alter(&$head_elements) {
  foreach ($head_elements as $key => $element) {
    if (preg_match('/drupal_add_html_head_link:alternate:.*/', $key)) {
      unset($head_elements[$key]);
    }
  }  
}
olaf.dietsche’s picture

I modified this slightly and checked additionally for #attributes/type being application/rss+xml

function MY_THEME_html_head_alter(&$head_elements) {
    foreach ($head_elements as $key => $element) {
        if (strpos($key, 'drupal_add_html_head_link:alternate:') === 0 &&
            isset($element['#attributes']['type']) &&
            $element['#attributes']['type'] == 'application/rss+xml') {
                unset($head_elements[$key]);
        }
    }
}
cord1’s picture

You find a possible solution here

tgeller’s picture

As the author notes, that only toggles the RSS icon on and off: Users could still go to the rss.xml address and get at all the data. Still, thanks for mentioning it.

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

KolesnikovD’s picture

Just create new node and assign URL alias "rss.xml" to it through path module. Then users will get only that node.

tgeller’s picture

Great idea!

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

dlshannon’s picture

What about limiting the RSS content to a minimum? Through Administration/Configuration/Web services/RSS publishing, I set the "Number of items in each feed" to 1 and the "Feed content" to "Titles only". So, I still have an RSS feed, but there's not much there. BTW, it seems like a simple solution to this would be to allow us to set the "Number of items in each feed" to 0.

kimu’s picture

I've posted another solution here http://drupal.org/node/1349530#comment-5827160

vacho’s picture

damondt’s picture

Quick and easy in the template.php of the theme in question.
function theme_menu_alter(&$items) {
$items['rss.xml']['page callback'] = 'drupal_not_found';
}

batigolix’s picture

The solution is a combination of removing the link from the theme and using hook_menu_alter to block access. See http://drupal.stackexchange.com/questions/3782/how-to-remove-the-feed-ic...