Archive

Author Archive

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.

Clarke Bishop CFWheels, ColdFusion, Splash CMS , ,

New Splash Tags for the Splash CMS

March 5th, 2010

I recently added several new Splash Tags for the Splash content management system. If you don’t know about Splash, read my Introduction to Splash article.

  • <s: find>
  • <s: children-each>
  • <s: children-first >
  • <s: children-last >
  • <s: ifFirst >
  • <s: unlessFirst >
  • <s: ifLast >
  • <s: unlessLast >

There’s a complete list of tags and documentation over on the GitHub Wiki. But, I’ll give you an overview and show you how to use these tags for a blog.

<s:find> This tag looks up a page and stores the page object so that subsequent tags can use that page object.

<s: children-each> The tag finds all the children of a page and loops over them.

<s: children-first > and <s: children-last > finds the first or last child page.

The rest of the tags are all used inside of a <s: children-each> tag. They check to see if the current child page is the first one, last one, or whatever.

Making a Blog page with Splash Tags

Let’s say you have a page named Blog, that has several posts that are child pages of Blog. Then, in the body for the blog page, put something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<h3>Articles</h3>
<s:find slug="blog">
  <s:children-each
  order="publishedAt desc"
  where="status='published'">
    <cfset thisChild = request.tags.currentChild>
    <cfoutput>
      <dt class="blogList">
         <a href="#thisChild.slug#">#thisChild.title#</a>
            | #DateFormat(thisChild.publishedAt, 'long')#</dt>
      <dd class="blogDesc">#thisChild.description#</dd>
    </cfoutput>
  </s:children-each>
</s:find>

<s:find slug=”blog”> finds the blog page, and then <s:children-each> loops over all the pages. By the way, <s:children-each> uses the CFWheels findAll model method, so all of the cool CFWheels parameters are available in <s:children-each>!

If you want to see an example of what this looks like, visit the DonorUp blog page.

All in all, that’s a lot of output for very little programming effort. That’s what I call the secret to programmer happiness!

Clarke Bishop CFWheels, ColdFusion, Splash CMS , ,