mod_rss: Reading RSS Feeds
- Ariadne >
- Library >
- Ariadne 2.6 >
- Manuals >
- Programmers Reference >
- Modules >
This module allows you to read RSS feeds and display items through Ariadne templates.
First, find an RSS feed to display, then create a template on pobject, called rss.html, like this:
<ul>
<pinp>
load('mod_rss.php');
$feed=rss::loadFromUrl('http://www.scripting.com/rss.xml');
$feed->ls('rss.show.html');
</pinp>
</ul>
Then create a template on pobject called rss.show.html, e.g.:
<pinp>
$item=getvar('item'); // get the rss item information
</pinp>
<li><pinp>
if ($item['title']) {
echo "<h3>".$item['title']."</h3>";
}
echo "<p>".$item['description']."</p>";
</pinp></li>
That's it. You now have an rss reader in Ariadne. It doesn't do much yet, but you can do a lot more.
Any element in the item of an rss feed is available in the $item array, with the name of the xml tag as the index in the array, e.g.:
<item>
<title> $item['title']
<link> $item['link']
<description> $item['description']
<pubDate> $item['pubDate']
<guid> $item['guid']
<author> $item['author']
<category> $item['category']
<enclosure> $item['enclosure']
etc.
There are a lot more ways to use the RSS module, see the list of methods below:
rss::loadFromUrl
rssFeed rss::loadFromUrl($url)
Reads an RSS feed from a URL.
rss::loadFromString
rssFeed rss::loadFromString($RSS)
Reads an RSS feed from a string.
rssFeed::reset
array reset()
Resets the internal list pointer. If the RSS feed is read from a URL, the RSS feed is requested again. It then returns the first item in the feed.
rssFeed::next
array next()
Advances the internal list pointer by one. It then returns the next item in the feed.
rssFeed::count
int count()
Returns the number of items in the feed.
rssFeed::current
array current()
Returns the current item in the feed.
rssFeed::ls
mixed ls($template, $args='')
This method walks through the rss feed one item at a time, and calls each item with the given template and arguments. It adds a single argument to each call: $item. This is an array with all the items elements in the XML feed.

