Mon Sep 10 22:28:00 UTC 2007

Radiant CMS - Showing the date of articles

Posted in Radiant CMS, Ruby on Rails at 10:28 PM by mohits

One of my sites (http://tec.onghu.com/) is powered by the Radiant CMS. As I continue to build that site, I shall put up some information about how simple things are done in Radiant.

One of the things that I have is a running list of articles that have been published on different dates. I wanted a simple way to print out the date next to the articles.

Here’s what you need to do for that:



<ul>
<r:find url="articles">
<r:children:each order="desc" status="published">
   <r:unless_content part="no_menu"><li><r:link /> [<r:date format="%b %d, %Y" />] 
</r:unless_content></r:children:each>
</r:find>
</ul>

Notice 2 interesting things in the code sample above.

  1. r:date format – this expects a formatting string similar to what strftime in Ruby/ Rails expects.
  2. r:unless_content part=”no_menu” – this tag is a bit that excludes some pages from being shown in the listing. Any page that has a part called ‘no_menu’ will not be listed. This is a common way to prevent CSS files from showing in the list.

That’s all there is to it. Leave a comment if you want any bit above clarified.