We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4948
    • 33 Posts
    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

      • 11055 ☆ A M B ☆
      • 3,112 Posts
      revo/evo?
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 15083
        • 697 Posts
        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 smiley



          • 4948
          • 33 Posts
          Thanks for the responses guys esp Jusmeig with your solution. Im working with the latest version of revo. Will speak to my client and see what he wants and take it from there. Im still learning about snippets and stuff in revo as Ive not really used CMS’s before so please bear with me if I ask silly questions. I know if I can get those four feeds sorted and displayed in normal html tags sorted in the correct order, ill definitely be able to style it.

          Chaps
            • 15083
            • 697 Posts
            no problem....if you dont ask you will never know!
            bug in te above code btw, $doc->load
            U will need to get the xml as a string first...the func about does not do that.
            My bad :0