Kentico CMS 6.0 Developer's Guide

RSS repeater + Data source

RSS repeater + Data source

Previous topic Next topic Mail us feedback on this topic!  

RSS repeater + Data source

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

The RSS repeater web part can be used to transform a page into an RSS feed. This means that when a page containing the web part is accessed, its response type is changed to application/xml and the content of the feed is rendered. This is useful typically if you want your feed to have a dedicated URL (i.e. not a URL of a page with a querystring parameter). The Atom repeater and XML repeater web parts can be used exactly the same way, but the rendered feed is in the Atom or XML format.

 

In the following example, we will create an RSS feed with forum posts, the same as in the previous example. But this time, we want the feed URL to be <application path>/Forums/RSS.aspx. Therefore, we will create a dedicated page with this URL which will contain the RSS repeater web part and which will be linked from the /Forums page.

 

 

 

Please note

 

The result of the following example can also be achieved using a single web part - the Forum posts RSS feed web part, which has a built-in Forum posts data source. Similarly, there are all-in-one web parts for other frequently used document types and objects (see the listing here).

 

The following example uses two separate web parts for educational purposes only.

 

 

1. Sign in to CMS Desk and select the Forums page from the content tree. Click New and choose the Page (menu item) document type.

 

devguide_clip1010

 

2. Choose the Create a blank page option. Enter RSS for Page name and click Save.

 

devguide_clip1011

 

3. The page opens in Design mode. Click the Add web part (AddWebPart) icon of the only web part zone on the page. Select the Data sources/Forum posts data source web part and click OK. Leave all its properties at the default values, which will result in the data source providing all forum posts from all forum groups on the site. Click OK.

 

4. Click the Add web part (AddWebPart) icon again and select the Syndication/RSS repeater web part. Click OK and enter the following in the Web part properties dialog:

 

Feed name: MyForumPostsFeed

Feed title: Corporate Site Forum Posts

Feed description: This is a sample feed of all forum posts on the Corporate Site.

Data source name: ForumPostsDataSource

Transformation name: CMS.RSSTransformations.ForumPosts

 

Leave defaults for the rest of the properties and click OK.

 

devguide_clip1012

 

5. Now we have the RSS feed created, but without the knowledge of the page's URL, site visitors have no chance to access it. This is exactly when the Feed link web part comes in handy. It is a simple web part which displays the RSS icon with a link leading to a URL specified in its properties. We will add it to the /Forums page.

 

Select the /Forums page in the content tree, switch to the Design mode and click the Add web part (AddWebPart) icon of the zoneLeft web part zone. Select Syndication/Feed link and click OK. Enter the following properties:

 

Link text: Forum posts RSS feed

Feed URL: ~/Forums/RSS.aspx

Feed title: My Forum Posts Feed

 

Leave defaults for the rest of the properties and click OK.

 

6. Sign out of CMS Desk and browse to the Forums page. You should see the RSS icon and link as highlighted in the screenshot below.

 

devguide_clip1007

 

7. Click the icon or link, your browser will detect that you are accessing an RSS feed and display its content. As you can see, the URL of the feed is actually the URL of the page where the web part is placed. The same URL can be used to access the feed directly both from a browser or a dedicated RSS reader program.

 

devguide_clip1013