Valid RSS feed

Overview

How to create your own RSS feed in Frog in three easy steps:

  1. Create an RSS page;
  2. Add an auto discovery link;
  3. Add a manual link to your feed;

Create an RSS page

First of all, we'll need to go to our Frog administration area. Login with a user that has the Administrator and/or Developer roles. Create a page called "RSS" and set its status to "Hidden". We do this because we want the feed to be available to our visitors, but we don't necessarily want it to show up in our main navigation area.

We set the layout and pagetype boxes to "none" to prevent a layout from messing with the XML formatting.

By going to the "Meta-data" tab of our rss feed page and changing the value of the slug field to "rss.xml", we make sure that the rss feed looks like it is coming from a plain text file instead of being generated on the fly.

Now we go back to the "Page title" tab of our rss feed page and we insert the following code into the page body:

<?php echo '<?'; ?>xml version="1.0" encoding="UTF-8"<?php echo '?>'; ?>
<rss version="2.0">
<channel>
 <title>My blog</title>
  <link>http://www.myblog.com/</link>
  <language>en-us</language>
  <copyright>Copyright <?php echo date('Y'); ?>, myblog.com</copyright>
  <pubDate><?php echo date('r'); ?></pubDate>
  <lastBuildDate><?php echo date('r'); ?></lastBuildDate>
  <category>any</category>
  <generator>Frog CMS</generator>
  <description>A blog about my stuff.</description>
<?php $articles = $this->find('articles'); ?>
<?php foreach ($articles->children(array('limit' => 10, 'order' => 'page.created_on DESC')) as $article): ?>
<item>
  <title><?php echo $article->title(); ?></title>
  <description><?php if ($article->hasContent('summary')) { echo $article->content('summary'); } else { echo strip_tags($article->content()); } ?></description>
  <pubDate><?php echo $article->date(); ?></pubDate>
  <link><?php echo $article->url(); ?></link>
  </item>
<?php endforeach; ?>
</channel>
</rss>

 

Add an auto discovery link

We want our browsers to be able to automatically discover that our rss feed exists, so we'll put something like this in the HEAD section of our site. This section would generally be part of the Layout we gave to our Homepage page.

<link rel="alternate" type="application/rss+xml" title="My blog RSS Feed" href="/rss.xml" />

Add a manual link to your feed

Lastly, we may want to manually add a link to our rss feed somewhere. Just insert a bit of HTML code like this:

<a href="/rss.xml" title="My rss feed">RSS feed</a>

Just as an example, see my rss feed