Blog posts tagged "asdf"

On the fourth day of Kirby Week, Four Island gave to me: An article about implementing RSS.

It's another day of Kirby Week which means another tutorial! Today's post will be short because there's not that much to dynamically creating an RSS feed. What's that, you say? You don't know what RSS is? Le gaspez!

RSS stands for Really Simple Syndication. It provides a list of your latest blog posts (or anything, really, RSS can also be used nicely for things such as comments) in a format computers can read. This way, a computer can more easily tell if you publish a new blog post, for instance, and notify anyone who wishes to be notified.

RSS is an XML specification, so the entire thing is based upon a system of tags. Let's get to writing it!

Create an rss.php file in your kirbyweek08 folder. The root tag is the <rss> tag, with a mandatory attribute (version) that has to be set to 2.0. So, our document current looks like this:

<rss version="2.0">
</rss>

Every RSS feed has to contain a <channel> tag with information about the feed in question. Let's populate it with some default data that you can change:

<rss version="2.0">
 <channel>
  <title>Kirby Week 2008</title>
  <link>http://example.org/kirbyweek08/</link>
  <description>A description! YAY!</description>
 </channel>
</rss>

The fields introduced above should be pretty self-explanatory. The next thing to do is to dynamically introduce the latest 10 blog posts into the <channel> tag. I've done that here: http://other.fourisland.com/kirbyweek08/?source=rss.php. Ensure you replace all instances of http://example.org/kirbyweek08/ in the code with the path to your blog.

So, now you've got a feed. That's great, however, people probably won't know its there. Open up your custom header.php file. Somewhere between your <HEAD> tags, add this snippet of HTML:

<LINK REL="alternate"
      TYPE="application/rss+xml"
      HREF="rss.php" />

Now that you have an RSS feed, there are other options to consider, such as using a service like Feed Burner to "burn" your feed. Feed Burner can track subscribers, links clicked on, suspicious uses and other things, for instance, making your feed look prettier with little widgets at the bottom of each post.

Currently, the URLs we use to access each of your blog posts are kind of ugly (they all contain read.php?id=). Tomorrow we'll focus on removing the query string from the blog post URLs.

Hatkirby on December 17th, 2008 at 12:38:32pm
👍 3 👎