14 July 2013

This snippet shows you how to customize views RSS feed title in Drupal. This example shows you how to create title for taxonomy feed, so that the title would be the term with it's parents.

Source code viewer
  1. /**
  2.  * Implements template_preprocess_views_view_rss().
  3.  */
  4. function THEME_preprocess_views_view_rss(&$vars) {
  5. if ($vars['view']->name == 'taxonomy_term' && $tree = taxonomy_get_parents_all(arg(2))) {
  6. $vars['title'] = '';
  7.  
  8. $tree = array_reverse($tree);
  9.  
  10. foreach ($tree as $term) {
  11. if (!empty($title)) $vars['title'] .= ' - ';
  12. $vars['title'] .= $term->name;
  13. }
  14. }
  15. }
Programming Language: PHP