Page is a not externally linkable
- Code, Content, and Presentation
-- RSS, ATOM, and Related Technologies
---- Limiting number of headlines isn't working


revtim - 9:41 pm on Jun 23, 2008 (gmt 0)


I added RSS feed using your simple guide. So far so good. Only one small hitch. I am getting about 35 headlines and I want to limit it to more like 20. I checked magpie and got this instruction.

You want to display the 10 (or 3) most recent headlines, but the RSS feed
contains 15.

SOLUTION:

$num_items = 10;
$rss = fetch_rss($url);

$items = array_slice($rss->items, 0, $num_items);

DISCUSSION:

Rather then trying to limit the number of items Magpie parses, a much simpler,
and more flexible approach is to take a "slice" of the array of items. And
array_slice() is smart enough to do the right thing if the feed has less items
then $num_items.

See: [php.net...]

I located the $rss = fetch_rss($url); in the feed.php code and replaced it with the above code since it is duplicated and expanded in the replacement code.

I uploaded feed.php to my site and nothing changed. Even when i open mydomain/rssdemo/feed.php there are still all the headlines. (yes, i ctl/refreshed to make sure)

So, where did I go wrong. I noticed this same question was asked when the simple guide was first posted but no one responded.

Thanks


Thread source:: http://www.webmasterworld.com/rss_atom/3681891.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com