How to theme Views RSS output (and include CCK fields) in Drupal 6

I continue to tweak and refine this site as I have time, and one of the things I recently fixed was the RSS display. (This will be technical mumbo-jumbo to some, but it may be helpful to folks who are using Drupal and want to do the same). I wanted to include a CCK field in the RSS feed display and theme it -- by default it was just using the Drupal setting (/admin/content/rss-publishing) which was in my case to display the title and teaser. Then it was tacking onto the bottom whichever CCK fields were visible in the teaser, but it was very unsightly.

I experimented with different .tpl.php files in my theme directory but was having trouble getting the Views RSS feed to pick up the changes. The solution I ended up using was simply to install the contemplate module, which made it extremely simple. All you have to do is go to the Content Templates page in your admin panel (/admin/content/templates), choose the content type that you wish to modify, and click "Create template."

This opens up a window giving you control over the display of the teaser, body, and RSS for the content type. I had already themed the teaser and the body using .tpl.php files, so I just modified the RSS setting on this page. The beauty of it is that it provides a clickable list of variables from your content type that can be inserted directly into the HTML code you are building for the output.

I'm beginning to think I should handle most of my custom theming for teaser and body this way, too. It makes it extremely easy to update and much simpler to paste the variables in. (Previously I spent a lot of development time using print_r ($node) to try to figure out how to refer to the variables in the .tpl.php files.

Hope it's helpful to someone.

Comments

Help with showing dynamic links in RSS Views

 Can I use Contemplate to get this dynamic links http://www.tinemuller.dk/drupal/list_copenhagen_feed to functioning? I have described my problem here http://drupal.org/node/570588. And after this didn't functioning I describe my new problem here http://drupal.org/node/581068. /Tine 

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
By submitting this form, you accept the Mollom privacy policy.