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

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. Click on the Site Browser tab and select a folder, then right click on it and click on: New --> HTML Page. 
  2. In the Add/Edit HTML Page screen enter the following information and click on Save.

    Note: You need to use a Blank Template (a template that doesn't have any headers or HTML only one container). 
  3. In Edit Mode, click on a Body Container: Add Content button and select "Add Widget". 
  4. A dialog box will display, select the widget type: Simple Widget on the left column and then click on "Create New Simple Widget".
  5. In the "Add/Edit Simple Widget" screen, enter the title: News - Atom Feed. In the code field use the following code and click on Save. The code creates the feed by outputting the xml tags required for the feed and by doing a content query on all News items. You can modify the content query to pull any other content you want to display on the feed. 
    #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/" />
            <updated>$date.get('yyyy-MM-dd')T$date.get('HH:mm:ss')Z</updated>
        <id>http://demo.dotcms.com/</id>
            #foreach($con in $dotcontent.pull("+contentType:News",10,"title asc"))
            <entry>
                    <title>$con.title</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>
    
  6. You can now preview your feed by clicking on 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.

Note: Here you can find more information about required and optional fields on your feed.