Add additional information to RSS in Drupal 7

Estimated reading time of this article: 1 minute

Do you want to add some additional text, e.g. a footer in RSS feeds of Drupal 7?

You could provide some hints or related news.

I've found a simple solution to do this. There are certainly other solutions or places in Drupal to do this.

<?php
/**
 * Adds some additional text for rss view_mode.
 * Implements hook_node_view().
 */
function YOUR_MODULE_node_view($node, $view_mode) {
  if ((
$node->type == 'article') && ($view_mode == 'rss' /*| $view_mode == 'full'*/)) {
   
$markup = '<hr><div class="rss-footer">' . t('Has the article been interesting? Would you like to share it?') .'</div><hr>';
    
$node->content['rss-footer'] = array(
     
//'#type' => 'markup', // The default value.
     
'#markup' => $markup,
     
'#weight' => 500,
    );
  }
}
?>