Creating an Atom Feed - Documentation topics on: atom,build rss feed,feeds,howto,rss,rss feeds,.

This documentation is a static copy for this version. For current documentation, see: http://dotcms.com/docs/latest

Creating an Atom Feed

The Atom Syndication Format is an XML language used for web feeds. Here's an example of how to take a dotCMS content type and create a widget to display an Atom feed.

Follow the next steps using the "News" content type from dotCMS' starter site:

1. Select Site -> Browser from the navigation panel.
2. Right-click on a folder and select New -> Page.

3. In the Add/Edit HTML Page screen enter the following information and click on Save:

Note: You must use a Blank Template (a template that doesn't have any headers or HTML only one container) for a page that generates an Atom feed.

4. In Edit Mode, click on a Body Container: Add Content button and select “Add Widget”.

5. In the popup select the Simple Widget Content Type in the left column.
6. Click on the Create New Simple Widget button.

7. In the Add/Edit Simple Widget screen:
  • Enter the title (e.g. “News - Atom Feed”).
  • In the Code field enter the following code:
    #if(!$EDIT_MODE)
        $response.setContentType("text/xml")
    #end
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <title>News Feed</title>
        <subtitle>Atom Feed Example.</subtitle>
        <link href="http://demo.dotcms.com/home/atom-feed.html" rel="self" />
        <link href="http://demo.dotcms.com/" />
        <id>http://demo.dotcms.com/</id>
        <updated>$date.get('yyyy-MM-dd')T$date.get('HH:mm:ss')Z</updated>
        #foreach($con in $dotcontent.pull("+contentType:News",10,"title asc"))
            <entry>
                <title>$con.title&lt;/title>
                <link href="http://demo.dotcms.com/news/${con.urlTitle}" />
                <id>http://demo.dotcms.com/news/${con.urlTitle}</id>
                <updated>$date.format('yyyy-MM-dd',$con.modDate)T$date.format('HH:mm:ss',$con.modDate)Z</updated>
                <author><name>$con.byline</name></author>
            </entry>
        #end
    </feed>
    
  • Click the Save button.

Note:

  • The code above creates the feed by outputting the XML tags required for the feed and then doing a content pull of all News items in your dotCMS content store.
  • You can modify the content pull to query any other content you want to display on the feed.
Preview the Feed

To preview the feed, select the Preview tab. This feed can be used by other sites to ingest dotCMS content and be displayed in external websites. Click on Publish Page to make your feed live. The feed can be accessed using an RSS reader.

References

For more information about required and optional fields in your Atom feed, please see the Atom documentation.