The current version generates a comma separated list inside the element. I needed a element for each category. I modified function theme_views_rss_fields_element in views_rss_views_fields.theme.inc to achieve that. On line 112 it says:

else {
  return "<$key>" . check_plain(htmlspecialchars_decode($value['#markup'])) . "</$key>";
}

I changed that to:

else {
  if ($key == 'category') { 
    $row_temp = '';
    if (strpos($value['#markup'], ',')) {
      $categories = explode(',', $value['#markup']);
        foreach ($categories as $category) {
          $category = trim($category);
          $row_temp .= "<category>".check_plain(htmlspecialchars_decode($category))."</category>";
         }
       return $row_temp;
     } 
  }
  return "<$key>" . check_plain(htmlspecialchars_decode($value['#markup'])) . "</$key>";
}

Maybe the maintainer can include this in a future update.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcho’s picture

Status: Active » Needs review
FileSize
920 bytes

How about a patch based on your proposal?

maciej.zgadzaj’s picture

Status: Needs review » Closed (fixed)

This feature has been implemented in both 2.x-dev branches.

Please note that they are still under development, most features should already work fine though (however be warned that things still could change there).

Also, would be great if I could get some feedback on them...

tthenne’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

This feature has been implemented in both 2.x-dev branches.

^I am using the 7.x-2.x-dev version and I have my ITEM ELEMENTS: category set to Tags. For my Tags field setting I have "display multiple items on same row checked" and I am using the simple separator ","

However, my tags are all still printing out in the same element as so:

<item>
  <category>Tag 1, Tag 2, Tag 3</category>
</item>

It would be great if I could wrap each of the tags in their own category as such:

<item>
  <category>Tag 1</category>
  <category>Tag 2</category>
  <category>Tag 3</category>
</item>

However, I'm not able to get this working. Also, I noticed that the core functionality of the views_rss module is changed in the newer versions so the patch in this thread no longer works. I believe the new function to process the <category> elements is views_rss_core_preprocess_channel_category

Any suggestions on how I can make this work? Thanks!

tthenne’s picture

Status: Closed (fixed) » Active
maciej.zgadzaj’s picture

Status: Active » Closed (fixed)

First, please do not re-open already closed issues. If you need help, please open new support ticket.

Then, for All taxonomy terms field there is no "display multiple items on same row" option - therefore I guess you are using different field, so it's quite possible it is not going to work as it was not tested/designed for other fields.

Please switch to All taxonomy terms field, use RSS <category> element field display type and create a new ticket if it still does not work for you.

tthenne’s picture

Thanks, that did it. Sorry for re-opening the status queue.