about RSS_aggregator with newst posts

about RSS_aggregator with newst posts

Postby mejia on Tue Nov 14, 2006 12:16 am

i read the article about RSS_aggregator

This code work to display all the channel (in this case of yahoo):

{if $rss->parse("http://rss.news.yahoo.com/rss/topstories")}
{assign var=channel value=$rss->getChannel()}
<ul style="list-style: none;">
{foreach from=$rss->getItems() item=rssItem}
<a href="{$rssItem->getLink()}">{$rssItem->getTitle()}</a><br/>

how cant I put only one post (the last) of a list of feeds?
Posts: 117
Joined: Tue Jun 15, 2004 7:43 pm
Location: mexico

Postby phunkphorce on Tue Nov 14, 2006 3:34 am

{$rss->getItems()} will return an arra with all the posts, I suppose something like this will do:

Code: Select all
{assign var=allPosts value=$rss->getItems()}
{assign var=lastPost value=$allPosts[0]}

Now you can use $lastPost and display the information in any way you like.

Please bear in mind that you should also check whether there really is at least one post, or else the code above will crash.
Lifetype Expert
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Return to Templates