Currently, all terms you put in the category field are concatenate in one < category > < /category > node.

this patch will split the value along commas (which is the default for Term fields) and create one < category > node for each value.

And it also nicely indents the xml (at the price of inserting spaces in the code).

CommentFileSizeAuthor
#3 categories_v2.patch3.43 KBbatje
#2 categories_v1.patch3.36 KBbatje

Comments

batje’s picture

Status: Active » Needs review

bumped status

batje’s picture

StatusFileSize
new3.36 KB

and attached the actual patch

batje’s picture

StatusFileSize
new3.43 KB

And in this patch the paths look much nicer.

This is my first folder patch (with diff -urp ) so if i did it wrong, let me know.

ccarigna’s picture

Status: Needs review » Reviewed & tested by the community

I was looking to do the same thing - split out multiple terms into separate category tags. Thanks for the patch - I've tested it and it works.

wernerglinka’s picture

Will this work with D7? Has anybody tested this with D7?

batje’s picture

Check out the http://drupal.org/project/feeds_tamper module That might work as a solution, too. And it has a D7 release.

wernerglinka’s picture

Thanks for the reply batje. The feeds_tamper module was my first option but it doesn't do what I want. A field <category>category1, category2</category> will result in a category category1,category2. I used feeds_tamper's explode but to no avail.
I have looked at the patch for the D6 version and will try to change that for D7 a little later. I'll will post here once that is done. In the mean time if anybody has additional suggestions I'll try them as well.

batje’s picture

perhaps you should first remove the <category> and </category>, using tamper, and then explode?

wernerglinka’s picture

@batje, thanks again for responding. I ended up modifying function theme_views_rss_fields_element in views_rss_views_fields.theme.inc with your D6 logic and that did the trick. 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>";
}

I have never done a patch so I hope people looking for a Drupal7 fix can use this solution.

maciej.zgadzaj’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Support for multiple categories added to most recent 6.x-1.x-dev version (from 2011-Nov-09). D7 version to follow.

Also, added first draft of module how-to - please read for what it can and can't do.