Easy, elegant news feeds with lastRSS
The RSS format is great for getting the lastest headlines in your favourite news reader. But what if you run your own website and you want to include some of these headlines on your own site?
You could always copy and paste them into your HTML, or even type them in yourself. But perhaps your best bet is to use the lastRSS PHP class to do all the hard work for you.
Why exactly this class is called “lastRSS” is anyone’s guess but, names aside, this is one of those great pieces of PHP code that does exactly what you need and yet is simple enough for even amateurs to make sense of it.
Simply put lastRSS is a PHP class that grabs a specified RSS feed and turns it into something that is easy to manipulate on the receiving end. So grab the www.tectonic.co.za/tectonic.rss news feed for example and split it into its various parts. Add a little HTML code and you’ve got a good looking set of news headlines to add to your site.
Okay, easy enough. Now, imagine that you only want to update the headlines every hour or so. lastRSS includes a setting for caching the headlines as they are updated. Set your
cache_time to one hour, or two, or even 24 hours and the feed will only be updated at that interval no matter how many readers your site has in a day, which means you will not be annoying the webmaster of your favourite site with thousands of requests for their RSS feed every hour.
Next, how about limiting the number of headlines you pull? Easy enough. Set the
items_limit to your preferred length. Or set your preferences for displaying the date format. Or stripping out extraneous HTML code from the feed, or CDATA information.
Basically, lastRSS does just about anything you could want of a useful on-site RSS headline grabber.