Can some one explain how I control the number of entries from RSS feeds that Magpie will display? The install instructions are pretty vague IMO. thx
Wow thanks. Code below. <?php //---Code to display RSS feeds using MagpieRSS include "magpierss/rss_fetch.inc"; //include the magpierss script define('MAGPIECACHEDIR', '/tmp/magpie_cache'); $url = 'http://website.com/forums/external.php'; //this is the url of the feed, enter your own url here $num_items = 2; $rss = fetch_rss( $url ); $items = array_slice($rss->items, 0, $num_items); $output = '<a target="_new" href="http://www.website.com/forums">website.com Forums</a><br><br>'; for ($i = 0; $i < sizeof($rss->items); $i++){ $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>'; $output .= $rss->items[$i]['description'].'<br><br>'; } echo $output; //--
for ($i = 0; $i < sizeof($rss->items); $i++){ PHP: is a loop that displays all feed items. You can change it in this way, from for ($i = 0; $i < sizeof($rss->items); $i++){ $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>'; $output .= $rss->items[$i]['description'].'<br><br>'; } PHP: to $max = 10; // put here the number of items to display for ($i = 0; $i < $max; $i++){ if ($i >= sizeof($rss->items)) break; // exit if current index is >= number of items even if < $max $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>'; $output .= $rss->items[$i]['description'].'<br><br>'; } PHP: It should fit your need.
Worked perfectly, thanks. One more question, how do I change the time interval that the script polls the rss feed?
It dipends how you set the routine that run the script. Did you used a cronojob? If you are talking about the cache, Magpie has 1 hour cache.