The reason there’s no RSS library is becuase RSS files are super easy to generate. Just create a view file with the appropriate RSS template. For example, here’s an RSS 2.0 template:
<?xml version="1.0" encoding="<?php echo $encoding; ?>"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo $feed_name; ?></title>
<link><?php echo $feed_url; ?></link>
<description><?php echo $page_description; ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; ?></dc:creator>
<dc:rights>Copyright <?php echo gmdate("%Y", time()); ?></dc:rights>
<dc:date><?php gmdate("%Y-%m-
T;%H:%i:%s%Q" time()); ?></dc:date>
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
<?php foreach($data as $row): ?>
<item>
<title><?php echo xml_convert($row->title); ?></title>
<link><?php echo $row->permalink; ?></link>
<guid><?php echo $row->permalink; ?>#When:<?php echo gmdate("%H:%i:&#xsZ;", $row->date); ?></guid>
<description><?php echo xml_convert($row->description); ?></description>
<dc:subject><?php echo xml_convert($row->category); ?></dc:subject>
<dc:date><?php echo gmdate"%Y-%m-
T;%H:%i:%s%Q", $row->date); ?></dc:date>
</item>
<?php endforeach; ?>
</channel>
</rss>
Obviously the variables will need to be swapped with real values, and the foreach loop needs to contain a valid query result, but the concept is no different then creating any other type of view file. You can do the same with atom feeds or whatever.
The only issue to be aware of with dynamically generated RSS feeds is you need to remember to send the appropriate server header or some browsers will not treat the file as an RSS feed:
@header("Content-Type: text/xml");
The only reason one might want an RSS class is to do “if-modified-since” headers, but other than than, RSS files are a piece of cake.
