Had a lot of emails since the last publication requesting that an RSS feed be created for Project: New. I was expecting a bit of a tricky scenario but to be honest, its fairly easy to do.
First we need to set the correct MIME type – XML and include the XML Prolog – this is to stop browsers sending the content as text/html:
Next we hard code some info about the site and subject the RSS feed is about:
After this comes the trickiest part of the whole thing – and it really isn’t tricky at all. We simply perform a query on the table that holds the data and loop through it, outputting the right field data into the right RSS tags:
And to finish off, we hard code our closing RSS tags:
Here’s the whole thing for your copying and pasting pleasure:
Surprisingly easy once you get into it, isn’t it? The added benefit of rolling your own RSS feed using PHP is that you can include stuff like stat tracking (e.g. Shortstat) – not possible if you’re relying on a CMS’ own RSS feeds.
It really is. I was very pleasantly surprised. I was expecting a crash course of a level of difficulty beyond me but as you say Matthew – surpisingly easy.