Create feed from node content

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

I'm wondering what would be the best way to generate a feed (xml file) for data associated with a node. I have a custom node type with a cck imagefield that allows multiple images to be attached. Think of the node as an album. What I would like to do when the node is created is to generate the appropriate feed file needed by piclens, but I'm unsure where is the appropriate place to do that.

One idea I had in mind was to create a custom module, and when the node is created/edited, create the actual file which would be needed by piclens. Wondering if there is a better/easier way of doing this :)

thanks.

Comments

Views + Contemplate

benroot's picture

You could try the Contemplate Module. It will let you use the UI to write some php code to display the RSS feed. Basically just set up the formatting and then iterate over your images and add them to the file. You will just need to know the format requirements of piclens.

Pseudo-code:

$str = '<piclensFile>';
foreach ($node->field_album_images as $image) {
  $str .= '<image>';
  $str .= '<title>$image->title</title>';
  $str .= '<url>$image->URL</url>';
  $str .= '</piclensFile>';
}
echo $str;

Thanks

dan.crouthamel's picture

Thanks. I'm familiar with contemplate and I'm using it for teaser/body now with some nodes. However, I thought the use of contemplate RSS and views only worked when I'm displaying a view, not a node, correct? Or is there a way for views to be used (when viewing a single node) in this case that I'm not thinking about?

haven't done it, but it should work

benroot's picture

Dan,

From Contemplate Documentation:

...But Content Template can actually be used on any node type and allows modification of the teaser and body properties before >they go out in an RSS feed, search index, or are handed off to the theme. Additionally, ConTemplate can choose to add any files, >images, or other media to RSS feeds as an attachment...

I haven't done it but it seems like this is a use case they designed the module for. Maybe the maintainers could help you out with more info. If you find out something good please let me know -- generating custom feed file types sounds cool to me! Would be good for making SimpleViewer gallery xml files too!

Thanks for the reply. But I

dan.crouthamel's picture

Thanks for the reply. But I think that applies at the time a feed is being generated. So if I'm viewing a view, you can use contemplate to modify the rss feed for that view. I've successfully used contemplate to do this. However, I don't think this works when viewing a single node - at least I haven't been able to figure it out and make it work :) How does one say that for this node, this RSS feed applies?

I suppose it doesn't matter now because last night I created a custom module to do what I need :)

RSS & Aggregation

Group organizers

Group notifications

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