You are here

function template_preprocess_views_rss_fields_item in Views RSS 6

Template preprocessor for views-rss-fields-item.tpl.php.

File

views/views_rss_views_fields.theme.inc, line 58

Code

function template_preprocess_views_rss_fields_item(&$vars) {
  $row = '';
  foreach ($vars['item'] as $key => $values) {
    if ($values) {
      switch ($key) {

        // <enclosure> element was already formatter before
        // by selected field formatter.
        case 'enclosure':
        case 'source':
          $row .= $vars['item'][$key] . "\n";
          break;
        default:

          // Some feed elements could contain multiple values (ie. 'Category'),
          // therefore let's first make sure that EACH feed element is an array
          // (even if it has one value only) and then loop through all of them.
          if (!is_array($values)) {
            $values = array(
              $values,
            );
          }
          foreach ($values as $value) {
            $row .= "<{$key}>" . $value . "</{$key}>\n";
          }
      }
    }
  }
  $vars['row'] = $row;
}