Create extra elements on rss feeds via CCK: aka, feedapi mapper partner in crime

Events happening in the community are now at Drupal community events on www.drupal.org.
Ian Ward's picture

I made a very rough implementation of a module that just uses the nodeapi 'rss item' op to add cck fields as extra elements in the item namespace. In RSS 2.0, adding extra elements is allowed as long as they're w/in a namespace on the spec., and Drupal's nodeapi makes this pretty easy to do. My question is, is there already some functionality out there that does this? What I do w/ this is just enable the module, then make a view with views and views RSS, and this little module pops in the cck fields into the item namespace. It seemed like views RSS does not do this itself, even if you add extra fields to the view. Has anyone seen anything in Drupal that's doing this? This functionality is basically the partner in crime for the feedapi mapper, which can then take these extra elements and populate cck fields when aggregating. Here you can see the source to see better what it's doing http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/development... and here's a screen shot to better depict what's up. I want to make sure there's not anything thats' already taking care of this before running any further on this.

AttachmentSize
Picture 6_12.png76.73 KB

Comments

No, I think you're clear -- go for it

boris mann's picture

There are some modules that insert extra data into RSS (events, etc.), but I believe they are from several versions ago.

Also, I can't visually see what you're inserting -- what are the extra elements in the feed above?

One of my to-dos has been to think about a drupal namespace -- the RDF API also needs to decide on a common drupal namespace.

In short, I think you're good to go.

hey Boris, sorry I didn't

Ian Ward's picture

hey Boris, sorry I didn't describe very well what I actually did :) I made a couple of text fields in CCK (length and producer) and created a "TV program" node type. This tiny module takes the values from any cck fields, uses their labels as the element name, and the values that the user entered on the node as the value. These all get added into the "item" namespace, using the given label of the cck field. In this example you can see "length" and "producer" were inserted into the feed. I've got to check out Arto's work w/ RDF, I just caught it this morning...but at a quick glance, it looks like perhaps CCK field mapping to RDF could be another tack to take w/ this.

Problem with field name with space

gagarine's picture

Thanks yan for your module. I found a litel bug with field with space in label.

I juste clean the field->label befor output:

<?php
/**
* Implementation of hook_nodeapi
*
* @abstract  Find the fields on the node and put then on the node as extra elements.
*
* @todo  Restrict to certain field-types
*        Attribute handling
*        Abstract to arbitrary XML maker based on views field labels and values.
*        
*/

function views_rss_extra_maker_nodeapi(&$node, $op) {
  switch (
$op) {
    case
'rss item':
     
$fields = array();
     
$query = db_query("SELECT field_name, label FROM {node_field_instance} WHERE type_name = '%s'", $node->type);
      while (
$result = db_fetch_object($query)) {
       
$field = $result->field_name;
       
$fieldarray = $node->$field;
       
$cleanLabel = strtolower($result->label);
   
$cleanLabel = preg_replace("/\s/", "", $cleanLabel);
       
$output[] = array(
                     
'key'  => $cleanLabel,
                     
'value' => $fieldarray[0]['value'],
                    );  
      }
    return
$output;
    break;
  }      
}
?>

thanks, just what i needed.

darrenmothersele's picture

thanks, just what i needed.

future plans

attiks's picture

Any plans on making this into a regular module?

Cheers,
Peter

Hi Peter, There is another

Ian Ward's picture

Hi Peter,

There is another developer who started implementing this around the same time as myself. I'm talking w/ him now. He plans to commit his implementation soon. I'll drop him a line now about this thread.

cheers,
Ian

Update?

akahn's picture

Hi Ian,

What's the story on the other developer you mentioned working on something similar? I'm curious about the current status of this effort.

Alex

This would be great

adamcarsonb's picture

I would really like to see this module take off. I've always wanted to show CCK fields in an RSS feed, but so far, only ugly, non-reusable hacks have been the answer. This is slick, real slick.

by the way, I'm trying out the code from CVS. I can't see the CCK fields in my view, and all I've done is add the CCK fields to my view. Is that all you have to do?

+1

nrasmus's picture

I would love to see this come together.

in what file does the above

xmvcnr's picture

in what file does the above code get inserted, and what directory, or do you create a new file? thanks for the code.

My rss feed is not updating

prettygirl's picture

hi friends,
i had a rss feed, that feed had a problem in updating the new items, it is showing me no items at syndication.
i had many doubts regarding this, they are:
Actually i had two xml feeds one contains only channel attribute and no items in that which i had attached to my website ,
for example:
rss
channel link website url /link /channel
/rss

and other xml file has many items ,
rss
channel /channel
items /items
/rss

so please tell me whether i had to attach the first one or second xml file.
if i paste second xml , it is showing me only the past written items in xml but not the updated items, what i must do for syndicating my new and updated items?
or they should be any linkage between 1st and 2nd xml file, does this belongs to coding error or my feeds errors ?
if any one knows solution for it please help me!

finally committed

kvantomme's picture

Today I finally committed the module Ian mentioned here. It doesn't have a release yet, as I'm waiting for some testing and community feedback. But you can check it out from CVS.

http://drupal.org/project/extra_RSS_fields

The story of the module (and the long wait) is in my blog post at http://www.pronovix.com/blog/presenting-extra-rss-fields-module-outputs-...

--

Check out more of my writing on our blog and my Twitter account.

Hi! I started a basic patch

Coornail's picture

Hi!

I started a basic patch for views_rss which can solve your problem: http://drupal.org/node/694552.

RSS & Aggregation

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: