Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | create_multiple_category_elements-1341884-1.patch | 920 bytes | pcho |
Comments
Comment #1
pcho CreditAttribution: pcho commentedHow about a patch based on your proposal?
Comment #2
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedThis 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...
Comment #3
tthenne CreditAttribution: tthenne commented^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:
It would be great if I could wrap each of the tags in their own category as such:
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_categoryAny suggestions on how I can make this work? Thanks!
Comment #4
tthenne CreditAttribution: tthenne commentedComment #5
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedFirst, 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, useRSS <category> element
field display type and create a new ticket if it still does not work for you.Comment #6
tthenne CreditAttribution: tthenne commentedThanks, that did it. Sorry for re-opening the status queue.