Which is the best script to show RSS news ?

Discussion in 'XML & RSS' started by poseidon, Jan 8, 2007.

  1. #1
    Ok guys, I am looking to introduce a news section in my technology site and want to display top tech news(from google if possible otherwise any other reputable source). I am looking for a nice, free but powerful script for this. Can anyone recomment me any such script ?

    Cheers
     
    poseidon, Jan 8, 2007 IP
  2. Tim_Myth

    Tim_Myth Peon

    Messages:
    741
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Magpie RSS.
     
    Tim_Myth, Jan 23, 2007 IP
  3. sabian1982

    sabian1982 Notable Member

    Messages:
    2,028
    Likes Received:
    161
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Tim, i understand xml although im struggling to understand how exactly to set up Magpie... as i understand it i simply put a snippet of code on my site where i want the information to be shown...

    ...then presumably i also upload the 4 .inc files somewhere... other than that i'm a little lost... could you provide some pointers or is there a walk through guide?
     
    sabian1982, Jan 26, 2007 IP
  4. Tim_Myth

    Tim_Myth Peon

    Messages:
    741
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm no expert with Magpie, but this is the code I use to display a feed:
    //Include our magpie functions
    require_once('rss_fetch.inc'); 
    //define our cache directory so we can cache the feed
    define('MAGPIE_CACHE_DIR', 'temp/cache');
    //set up our URL..much simplified in this case
    $url = "http://news.google.com/news?ned=us&topic=h&output=rss";
    //get our feed
    $rss = fetch_rss( $url );
    //If we got a feed, let's process it
    if ( $rss ) {
      echo '<h3>Top Google News</h3>';
      echo '<table style="border: solid black 1px;">';
      //Loop through all the items in the feed...
      foreach ($rss->items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        $description = $item['description'];	
        //And print them
        echo "<tr><td><a href=$href>$title</a></td><td>$description</td></tr>";
      }
      echo "</table>";
    }
    Code (markup):
    Each RSS object will have all the properties of the RSS feed used, so if the feed contains elements like pubDate or copyright, they could be accessed as well like this: $item['pubDate'] or $item['copyright']
     
    Tim_Myth, Jan 26, 2007 IP
  5. sabian1982

    sabian1982 Notable Member

    Messages:
    2,028
    Likes Received:
    161
    Best Answers:
    0
    Trophy Points:
    210
    #5
    Thanks, i appear to have got it working :D

    However now im trying to get it working in a tpl file of phpLD script and thats seems to be causing some issues...
     
    sabian1982, Jan 27, 2007 IP
  6. Tim_Myth

    Tim_Myth Peon

    Messages:
    741
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Umm... I have a plugin that will add rss feeds to phplid already: http://www.after5webdesign.com/phpBB2/viewtopic.php?t=177 It will use either the bread crumb trail (eg: directory >> shopping >> weddings) with the V2 plugin, or that category's keywords with the V3 plugin.

    However, you can wrap that code in {php} tags and place it in your tpl (main.tpl maybe?) file, or you can place it in your php file (index.php for example) and assign the $rss array to the template like this:
    $tpl -> assign ('rss', $rss);

    It's then a simple matter of using a section or foreach loop to loop through the rss array.
     
    Tim_Myth, Jan 27, 2007 IP
  7. sabian1982

    sabian1982 Notable Member

    Messages:
    2,028
    Likes Received:
    161
    Best Answers:
    0
    Trophy Points:
    210
    #7
    Ahhh see i've been wrapping it in normal php tags... so it needs to be in {php} tags... as without it appears to intefer with the smartclass...
     
    sabian1982, Jan 28, 2007 IP