Make an RSS Feed for Your Splash Site
March 6th, 2010
Using the new Splash Tags for the Splash CMS, you can easily make an RSS feed or an XML sitemap.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 <cfcontent type="text/xml" reset="Yes"><?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://www.YourSite.com/index.cfm/feed"
rel="self" type="application/rss+xml" />
<title>YourSite.com</title>
<link>http://www.YourSite.com</link>
<description>Your Description Goes Here</description>
<cfoutput>
<pubDate>#HTMLEditFormat(DateFormat(now(), 'ddd, dd mmm yyyy'))#
#HTMLEditFormat(TimeFormat(now(), 'HH:mm:ss'))# EST</pubDate>
<language>en-us</language>
<ttl>40</ttl>
<s:find slug="blog">
<s:children-each order="publishedAt desc" where="status='published'">
<item>
<cfset thisChild = request.tags.currentChild>
<title>#HTMLEditFormat(thisChild.title)#</title>
<description><![CDATA[<s:content part="body" page="#thisChild#"/>]]></description>
<pubDate>#HTMLEditFormat(DateFormat(thisChild.publishedAt, 'ddd, dd mmm yyyy'))#
#HTMLEditFormat(TimeFormat(thisChild.publishedAt, 'HH:mm:ss'))# EST</pubDate>
<guid isPermaLink="true">http://www.yoursite.com/index.cfm/#thisChild.slug#</guid>
<link>http://www.yoursite.com/index.cfm/#thisChild.slug#</link>
</item>
</s:children-each>
</s:find>
</channel></cfoutput>
</rss></cfcontent><cfabort>
Most of this code is the required RSS XML. Just drop in your site-specific domain name, description, etc.
The <s:find slug=”blog> tag finds the blog, and then <s:children-each> loops over all the children that are under the blog page. I used thisChild as a convenience variable instead of having to type request.tags.currentChild every time. The <cfabort> at the end keeps Splash from adding extra HTML tags at the end of the file.
You could also create an easy XML site map using a similar approach. Just change out the XML wrapper.
