I have an RSS feed reader that takes several different feeds, sorts the feeds using the Simplepie function, then it cache's the stories with Simplepie and displays all the news items by newest news item first. I have been trying to add a function to the rss feed reader so that each news item will display an image or logo for that feed, regardless of whether the feed has an image or not.
So ultimately if i have 9 news stories from 3 rss feeds, each of those feeds will display an image or logo that i have stored on MY website. The reason is many websites don't bother with logo's, pictures or images in their feed and it makes the news boring to read. So i want to make the feeds more interesting to read by adding images associated with that website.
How I'm doing this;
I have added the code to the feed-reader.xml file so each XML feed has a URL for an image i have stored on my website like this;
BBC news ; feed_url01 ; http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml
And i also have this line for each feed;
BBC news image ; feed_url01_img ; /images/news_images/bbc-news.png
So that is what is stored in MySql database. I have done that for all my feeds, I'm just adding "_img" for each URL so each feed has an extra input box to add a URL for an image. these get stored in the database.
So in the MySql database, each feed has 2 params like this;
feed_url01=http://www.my-freed-url.com/feed.xml
feed_url01_img=/images/news_images/bbc-news.png
In the PHP page feed-reader.php, which displays the feeds, i have added this to get the image params;
$feed_url01_img = $params->get('feed_url01_img','');
$feed_url02_img = $params->get('feed_url02_img','');
$feed_url03_img = $params->get('feed_url03_img','');
Then lower down the page i added this to display the images;
<!-- feed project image 1 -->
<?php if($feed_url01_img) { ?>
<img src="<?php echo $feed_url01_img; ?>" />
<?php } ?>
<!-- feed project image 2 -->
<?php if($feed_url02_img) { ?>
<img src="<?php echo $feed_url02_img; ?>" />
<?php } ?>
<!-- feed project image 3 -->
<?php if($feed_url03_img) { ?>
<img src="<?php echo $feed_url03_img; ?>" />
The problem, and why its not working!!!
So the end result here is that every single news item displays ALL the images.
Can anyone help. What should i change so only the BBC news items will display the BBC news image and the same for each news item feed displayed.
In the PHP page, i'm calling <?php if($feed_url01_img) { ?> but its adding the image to all the news stories, not just the BBC news story. This seems to be related to the way the cached files are stored using the Simplepie function. Somehow i need a function that will just add the image along with the selected news story.
I would appreciate any help with this.
Thank you,
John.