How can I add a node item to my rss output?

this is the normal item i get:

<item>
 <title>some kind of title</title>
 <link>www.somelink.com</link>
 <description>some description, etc etc</description>
</item>

but I want to add extra nodes inside the items:

<item>
 <title>some kind of title</title>
 <link>www.somelink.com</link>
 <description>some description, etc etc</description>
 
 <extranode1>extra data</extranode1>
 < extranode2>extra data</extranode1>
 etc etc

</item>
if I add stuff in the rss template it becomes available inside the <description> ... 
like <?php print $node->images[preview] ?>  ... 

any help ? :-)

Comments

jorisx’s picture

So I can't add a custom node in my items rss file?
because now I have to parse the body field for all my custom variables ... which is not really handy

anny help?

drywall’s picture

Category: support » bug

I'm having this same problem. Contemplate bills itself as giving "full control" over how Drupal outputs nodes but for RSS it only seems to affect what gets dropped into the <description> tag.

jrglasgow’s picture

Category: bug » feature

ConTemplate (Content Template) is to be used as special formating for content inside the wrapper that is provided by the theme. In the Garland Theme node.tpl.php file you will find a div

<div class="content">
    <?php print $content ?>
</div>

this is used for the teaser and the body.

For rss Contemplate was designed just to modify the content in the description tag, I'm sure what you are looking for can be accomplished, but I would classify it as a 'feature request' not a 'bug report'

drywall’s picture

You're probably right that it should be classified as a feature request. I guess I consider(ed) it a bug simply because in the Contemplate admin it says, "Please note that by creating a template for this content type, you are taking full control of its output" and to me "full control" != "just the description tag".

jorisx’s picture

Okey feature request it is ...
so what we need is a way to create our own tags in the rss so we can take "full control" of our output :)

Any ideas on how to hack this in to this module?

jrglasgow’s picture

take a look at contemplate 5.x-2.0

youngbuddha’s picture

Hi all,

With Contemplate 6.x-1.x-dev (2008-04-22) and Drupal 6.2, I am seeing the same behaviour as the original poster, i.e the description tag is clobbered but additional XML elements don't show up. Should I be using the older 6.x-0.7 release?

I have inserted the following PHP code into my "affect RSS block", with the checkbox enabled.

  $xml_elements = array(
    array(
      'key' => 'color',
      'value' => 'blue',
    ),
    array(
      'key' => 'rating',
      'value' => '5',
    ),
    array(
      'key' => 'widicon',
      'attributes' => array(
        'link'  => 'somewebsitelink',
        'size' => '176x220',
      ),
    ),
  );

Thanks for your time.

jorisx’s picture

Cool, this works really well with 6
I only installed contemplate (no other cck modules)

and I needed the image urls in the xml,
so I added this in the xml template:

<?php
  $imageurl = $node->images[preview];
  $imageurl = str_replace(' ', '%20', $imageurl);
  $xml_elements = array(
    array(
      'key' => 'imageUrl',
      'value' => $imageurl,
    ),
   );
?>

or 

<?php
  $xml_elements = array(
    array(
      'key' => 'imageUrl',
      'value' => str_replace(' ', '%20', $node->images[preview]),
    ),
   );
?>

and check it at your-website/rss.xml

hpk’s picture

Version: 5.x-1.9 » 6.x-0.3
<?php 

$education = $node->field_people_education[0]['safe'];
$school = $node->field_people_school[0]['safe'];
$body = $node->teaser;

$xml_elements = array
(

  array
  (
     'key' => 'education',
     'value' => $education,
  ),

  array
  ( 
     'key' => 'school',
     'value' => $school,
  ),

  array
  (
     'key' =>'body',
     'value' =>  $body,
  ),

);
?>

I am using the above code to output custom fields (cck 6.x-2.0-beta) the code is working however the description field is empty (thats why the $body variable). What can I do to fix this?

jorisx’s picture

I think I had the same problem, i've added this :
the body is an array, so you need to get the some value ...
(i'm not really into php, just copy/past and hacking my way trough it)

    array(
      'key' => 'imageDesc',
      'value' => $node->content['body']['#value'],
    ),

so for your xml it would be:

  array
  (
     'key' =>'body',
      'value' => $node->content['body']['#value'],
  ),
sillygwailo’s picture

The $xml_elements array works great for adding elements in version 2 of the Drupal 5-compatible module. What I'd like is to be able modify the existing elements. So for example, instead of the
element using the URL of the post, I'd like it to have the URL I'm pointing people using a Link field.

Right now if you add the following code:

$xml_elements = array('link' => [proper variable here]);

it will add another
element to the end instead of modify the existing one. Is replacing an RSS feed's elements possible?

bradjones1’s picture

I'll throw in my support for this kind of behavior; the teaser and body contemplate fields effectively override the entire output of the node in a particular setting; I'd like to do the same with each node's rendition in an RSS feed.

Like Richard, I'd like to point RSS readers to a link, rather than bounce them off a node view on our site that doesn't really get them to where they need to go.