dotCMS - Open Source Content Management System, Ondemand CMS, and Professional Support

Document Search

Article Information

Since Version: 1.6.5
Tags: Build RSS Feed
Updated: 11/21/2008 11:14:57 AM
By: Dean Gonzalez
Doc id: 151336
Print Page: Export to PDF

Build RSS Feed

This macro generates a RSS xml from a map list. Then name of the keys in the map have to be: 'title' (String - required), 'link' (Identifier - required), 'description' (String - required), 'guid' (Identifier -required), 'pubdate' (Date - optional) and 'author' (String - optional). This macro uses the permalink macro to generate the items link in the RSS.

Macro Overview:

Syntax:

#buildRSS(channelTitle channelLink channelDescription list)

Arguments:

  • channelTitle
    This is the value for the title tag of the channel.
  • channelLink
    This is the value for the link tag of the channel.
  • channelDescription
    This is the value for the description tag of the channel.
  • list
    This is the map list of contents to display in the RSS.

Optional Parameters:

  • channelLanguage (velocity variable not a parameter)
    This is the value for the language tag of the channel.
  • channelCopyright (velocity variable not a parameter)
    This is the value for the copyright tag of the channel.
  • channelPubDate (velocity variable not a parameter)
    This is the value for the publication date tag of the channel.
  • channelLastBuildDate (velocity variable not a parameter)
    This is the value for the last build date tag of the channel.
  • channelDocs (velocity variable not a parameter)
    This is the value for the docs tag of the channel.
  • channelGenerator (velocity variable not a parameter)
    This is the value for the generator tag of the channel.
  • channelManagingEditor (velocity variable not a parameter)
    This is the value for the managing editor tag of the channel.
  • channelWebMaster (velocity variable not a parameter)
    This is the value for the Web Master tag of the channel.
  • channelWebMaster (velocity variable not a parameter)
    This is the value for the Web Master tag of the channel.
  • permalinkDetailPage (velocity variable not a parameter)
    This is the identifier of the page that we need to display the contents in the item link. It uses the permalink macro.

Usage:

The macro will display all the content obtained by the pullcontent macro in the RSS
Examples:

Example 1: A simple example using the required fields

#set($contentList = $!{contents.getEmptyList()})
 #pullContent($query '0' 'modDate desc')
 #foreach($content in $list)
  #set($item = $!{contents.getEmptyMap()})
  #set($_dummy = $item.put('guid', $!content.get('identifier')))
  #set($_dummy = $item.put('title', $content.get($titleField)))
  #set($_dummy = $item.put('description', $content.get($descriptionField)))
  #set($_dummy = $item.put('link', $!content.get('identifier')))
  #set($_dummy = $item.put('pubdate', $!content.get('contentLastModDate')))
  #set($_dummy = $!contentList.add($item))
 #end
#buildRSS('Channel Title','http://hostname/test/test.dot','Channel description', $contentList)

Example 2: An example showing how to include one or more of the optional parameters

#set($permalinkDetailPage='123')
#set($contentList = $!{contents.getEmptyList()})
 #pullContent($query '0' 'modDate desc')
 #foreach($content in $list)
  #set($item = $!{contents.getEmptyMap()})
  #set($_dummy = $item.put('guid', $!content.get('identifier')))
  #set($_dummy = $item.put('title', $content.get($titleField)))
  #set($_dummy = $item.put('description', $content.get($descriptionField)))
  #set($_dummy = $item.put('link', $!content.get('identifier')))
  #set($_dummy = $item.put('pubdate', $!content.get('contentLastModDate')))
  #set($_dummy = $!contentList.add($item))
 #end
#buildRSS('Channel Title','http://hostname/test/test.dot','Channel description', $contentList)



Post a Comment


Add Comments

   

 
Post

Powered by Olark