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.
I have few questions:
1) how to add a namespace ?
2) how to specify additional elements ?
See the example below:
<?xml version="1.0" encoding="utf-8" ?>
<rss xmlns:g="http:// 1) HOW TO SET A NAMESPACE HERE ? " version="2.0" xml:base="http://localhost/test">
<channel>
<title>this is the basic option title</title>
<link>http://localhost/testrss</link>
<description>this is the RSS description on the style setup</description>
<language>it</language>
<item>
<title>Item 1 title</title>
<link>http://localhost/content/test1</link>
<description>test description</description>
<g:id> 2) THESE ELEMENTS </g:id>
<g:condition> ARE ADDITIONAL </g:condition>
<...> (AND SHOULD BE CONFIGURABLE) </...>
</item>
<item>
... item2... item3...
Thanks In Advance !
Comments
Comment #1
edunn CreditAttribution: edunn commentedIf you don't mind hacking the plugin a little bit, you can add whatever fields you want in views_plugin_style_rss_fields.inc at line 91 where it says function xml_fields(){
mine looks like this now:
Comment #2
mandreato CreditAttribution: mandreato commentedThanks edunn, I'll give it a try
Comment #3
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedJust pushed new 6.x-1.x-dev version, providing
hook_views_rss_elements_alter($elements)
for adding new user-defined fields.Also, when new fields are added, and if new namespaces are to be configured, they will automatically appear in view's style settings (
Feed settings
/XML namespace definitions
).Please pull new version from repository or allow up to 12 hours for d.o to regenerate downloadable package.
Comment #4
mandreato CreditAttribution: mandreato commentedThank you maciej.zgadzaj !
I've created a module to extend Views RSS for Google Merchant Center feed format as suggested in http://drupal.org/node/1346506, then specified the URI for "g" namespace (http://base.google.com/ns/1.0). Finally assigned a field to "Google Merchant Center product ID" RSS Feed field.
The generated XML shows all the informations, but misses the namespace (xmlns=...).
Comment #5
mandreato CreditAttribution: mandreato commentedHere is how to show the missing namespace: on views_plugin_style_rss_fields.inc at line 329, add the following:
Hope This Helps !
Comment #6
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedJust a quick update on this - I am not committing this patch, and rather not going to, as at the moment I am in the progress of a huge refactoring, adding new features and fixing existing issues (including this one) - probably when the version I am working on becomes more or less usable I will just release it as 2.0-dev...
Comment #7
druth CreditAttribution: druth commentedHaving the same issue adding namespaces, mandreato I used the code from #5 and after a cache clear the namespaces are still not appearing, did you have to make any other modifications?
Comment #8
mandreato CreditAttribution: mandreato commented@druth_hpl, I don't use this module anymore but, as far as I can remember, #5 was the only modification I did to have the namespaces on 6.x-1.x-dev.
Comment #9
abudev CreditAttribution: abudev commentedI used the code from #5 too and the namespaces are still not appearing...Some other solution?
Comment #10
PHLAK CreditAttribution: PHLAK commentedI tried the fix suggested in #5 but that didn't seem to help. Is there any more information or status on a fix?
Comment #11
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedI have just pushed new 6.x-2.x-dev version, which should resolve your issues.
It provides 3 new hooks:
hook_views_rss_channel_elements_alter($elements)
,hook_views_rss_item_elements_alter($elements)
andhook_views_rss_namespaces_alter($namespaces)
, through which other modules can modify existing or define new<channel>
and<item>
elements as well as any extra required namespaces.These hooks are used by 3 additional sub-modules coming together in the package: views_rss_core (providing basic set of channel and item elements, needed for the feed to be created at all), views_rss_dc (Dublin Core elements) and views_rss_georss (GeoRSS elements).
Please note that it is still under development, so things still could change, most main features should work fine though. I would love to get some feedback if any of you guys feel like giving it a test run and letting me know your thoughts.
Comment #12
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commented