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
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?
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']
Thanks, i appear to have got it working However now im trying to get it working in a tpl file of phpLD script and thats seems to be causing some issues...
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.
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...