Quote from: Chaps at Mar 30, 2011, 03:34 AM
Hi Guys,
My client subscribes to 4/5 rss feeds - I think he uses google reader but I think I can get him to change if need be. He would like his rss feeds to appear somewhere on the website within the news page (save him from typing it up in the news page), whats the best way to approach this as I have a nice website designed in revolution with clean css and whatever the feed displays, I would like formatted to use the same colours as the website.
Any ideas the best way I can implement this without it looking like a sore thumb? We are obviously aware that when you click on the link it will go to the website that had the original content.
Thanks
There are several snippets available in the repo for working with RSS feeds, however they will usually just parse/cache and display a single feed.
U could easily use a class like Magpie RSS with EVO/REV to (or do it yourself as Magpie is quite old):
1. Parse your RSS feeds (one at a time)
2. Join the above together in your snippet
3. Cache this "uber feed"
4. Output the lot...
Such a snippet might go something like this:
$doc = new DOMDocument();
$doc->load('http://www.pathtomyxml.com/feed.xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node)
{
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
);
array_push($arrFeeds, $itemRSS);
}
U can then add logic to do this per feed to have an array with all your items from each feed.
Loop through this "master" array then to output:
$output = '<ul>';
foreach($arrFeeds as $item)
{
$output .= '<li><a href="'.$item["link"].'">'.$item["title"].'</a></li>';
}
$output .= '</ul>';
This will give u a big UL of all the feeds.
To make this usable I would wite the output to a TXT file with a timestamp on it.
At the top of the snippet open the TXT file and checkk if the feed(s) is out of date. If not output the txt file and use a regex to remove the timestamp. Thats the caching done