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

[Edited for clarity]

Comments

Disable the module

Disable the Aggregator module?

- Ryan

Trying to disable RSS *publishing*, not subscription

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

RSS Permissions (no D7 release...yet?)

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.)

Going into D8, maybe

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

Port to Drupal 7

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.)

Just a quick note to

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

theming hack to remove feed link and icons

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.

Feature request

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.)

Removing feed link

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!!

<?php
/*drupal_add_feed('rss.xml', variable_get('site_name', 'Drupal') . ' ' . t('RSS'));*/
?>

Hi @jmanarivo, modifying core

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.

I find it ridiculous that RSS

I find it ridiculous that RSS is enabled by default.

hook_html_head_alter

(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;
}
}
}

based on dblue solution

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]);
    }
  } 
}

Possible solution

You find a possible solution here

Possibly useful for some cases, but...

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

How about shrinking the RSS content?

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.

Another solution

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