tags:

views:

8

answers:

2

I am combining two feeds, with enclosures, and items that don't have enclosures are showing up with empty enclosures.

Here's the code with the offending bit in bold:

<item>
<title><?echo $item->get_title(); ?></title>
<guid><? echo $item->get_permalink(); ?></guid>
<link><? echo $item->get_permalink(); ?></link>
**<? if ($enclosure = $item->get_enclosure()) {echo "<enclosure url='"
.$enclosure->get_link() ."' length='" .$enclosure->get_length() ."' type='"
.$enclosure->get_type() ."' />";} ?>**
<description>
<? echo $item->get_title(); ?>
</description>
</item>

Items with no enclosures show up with an empty enclosure url, length, and type:

All real enclosures show up as they should with url, length and type. I read a few threads on the Simplepie support page, but came up with no solution.

Thanks!

A: 

I don't know about Simplepie, but looking at the code, $item->get_enclosure() probably returns an object that evaluates to true, but is empty. So maybe you should change the condition of the if to:

<? $enclosure = $item->get_enclosure(); if ($enclosure->get_link()) {...
cambraca
A: 

That worked beautifully.

Funny thing is that I copied that code directly from the Simplepie documentation.

Thanks for the help!

Russ Turley