I'm using LastRSS to display RSS feeds from sites. The trouble is that some feeds contain long lists of links. I don't want to clutter a page with all of the links. Does anyone have a solution for limiting the display to just the first link, title and description?
With links do you mean feed items? If yes, since lastRSS returns an associative array with RSS items, just select the first array index ( 0 ).
Yes, I do mean feed items. I tried this: $item = $rs->rssarray['items'][0]; { echo "\t<li> title=\"$item[description]\" href=\"$item[link]\">".$item['title']."</a></li>\n"; } PHP: It displays just one bullet point with no text. No error message. Any idea what's wrong? Thanks.
I don't see any items when using that line. Here's the code currently being used: <?php // include lastRSS include "lastRSS.php"; // Create lastRSS object $rss = new lastRSS; // Set cache dir and cache time limit (1200 seconds) // (don't forget to chmod cache dir to 777 to allow writing) $rss->cache_dir = './temp'; $rss->cache_time = 1200; // Try to load and parse RSS file if ($rs = $rss->get('http://www.clickfire.com/viewpoints/blog/feed/')) { // Show last published articles (title, link, description) echo "<ul>\n"; foreach($rs['items'] as $item) { echo "\t<li> <a title=\"$item[description]\" href=\"$item[link]\">".$item['title']."</a></li>\n"; } echo "</ul>\n"; } else { echo "Error: It's not possible to reach RSS file...\n"; } ?> PHP:
<?php // include lastRSS include "lastRSS.php"; // Create lastRSS object $rss = new lastRSS; // Set cache dir and cache time limit (1200 seconds) // (don't forget to chmod cache dir to 777 to allow writing) $rss->cache_dir = './temp'; $rss->cache_time = 1200; // Try to load and parse RSS file if ($rs = $rss->get('http://www.clickfire.com/viewpoints/blog/feed/')) { print_r($rs); /* // Show last published articles (title, link, description) echo "<ul>\n"; foreach($rs['items'] as $item) { echo "\t<li> <a title=\"$item[description]\" href=\"$item[link]\">".$item['title']."</a></li>\n"; } echo "</ul>\n"; */ } else { echo "Error: It's not possible to reach RSS file...\n"; } ?> PHP: Could you print here the output?
It doesn't output anything with the above. Could it be because I'm using version lastRSS 0.9.1 class?
I don't really know, I've never used lastRSS. Try using Magpie RSS. http://magpierss.sourceforge.net/ <?php $url = 'http://www.clickfire.com/viewpoints/blog/feed/'; require('rss_fetch.inc'); $rss = fetch_rss($url); if ($rss) { // print the first item if (isset($rss->items[0])) { $item = $rss->items[0]; echo "<ul>\n"; echo "\t<li> <a title=\"$item[description]\" href=\"$item[link]\">".$item['title']."</a></li>\n"; echo "</ul>\n"; } } else { echo "Error: It's not possible to reach RSS file...\n"; } ?> PHP: