CCK Fields in Views RSS

Ron Williams - November 27, 2007 - 03:10

A rather frustrating problem I've ran into recently. I have 3 cck text fields within a node-type that need to be displayed in the views RSS feed. I've tried contemplate, but this only allows a selection of one field to be used in the rss feed at a time.

I've tried the following:
- Selected full node view
- Added the fields I wanted to use within the view and used table and list views
- Tried contemplate, but as stated above only allows one field to be used in rss at a time.

Please someone help me out, or is this issue resolved in views 2 in drupal 6 core?

Create your own module and

WoozyDuck - December 5, 2007 - 21:31

Create your own module and add the following function to it:

<?php
// node api hook
function yourmodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)
{

    switch(
$op)
    {
        case
'rss item':
       
            if(
$node->type=='story')
            {               
               
$node->title = "Add some CCK here too".$node->title;
               
$node->teaser = $node->field_from_cck['0']['value'];
            }
     
        break;
    }

}
?>

In my case

whalebeach - February 20, 2008 - 23:37

In my case, I like to include the teaser fields into views rss and the following code seems to be working.

    case 'rss item':
      $cck_nodetype = array('a','b','c','d','e'); // a,b,c,d,e are names of cck nodetype
      if(in_array($node->type,$cck_nodetype)){
        content_view($node,true,false);
        foreach ($node->content as $field) {
          $node->teaser .= $field['#value'];
        }
      }
      break;

 
 

Drupal is a registered trademark of Dries Buytaert.