This task is for users with the following roles: OC Developer.
In OpenCities, you can create content lists or RSS feeds. Both options consume data from your site's content and display it, but while content lists are used to list content from your site on other pages of your site, RSS feeds are better suited to consume OpenCities data and display it somewhere else.
For example, you could create an RSS feed that displays news, events, meetings, or general updates for your city or council. Your residents could then use the RSS link with an RSS reader to display a simple list of content that would link back to your site, or another website could use the link to display your content.
This article will go through creating an RSS feed, using the example of listing OC News Article pages outside of the site. The feed will present links to news articles on your site, displaying the title, page activation date, and a short description.
- Go to More > Content Lists from your main menu and select Create New Content List.
- Give your list a Name, and make sure you check RSS Feeds under List type.
- Choose your other settings in the Overview tab, then check OC News Article under Type of content to list.
- Switch over to the Sort & Filter tab and select your General, Sort options and Search Parameters settings. You may want to include news from different sites; check all that apply under General > Content groups.
- Under Sort options, we recommend using the following to display your content by the most recently activated first:
- Field: Activate Date
- Sorting Method: Start Date
- Direction: Desc
- For Edit Template options, only Body Top, Item, and Body Bottom are relevant, as RSS is just for listing, and we don't need to worry about presentation. RSS feeds are used to output data in a format that is friendly for other applications. Use the relevant code snippets below to input your data into each template.
- Save your list.
- To add an RSS feed to a page, you'll need to go to the WYSIWYG Editor of the page and select the Hyperlink Manager icon in the WYSIWYG toolbar.
- Go to the InternalLink tab, open RSS links in the content tree, and select the feed name.
- Select any further options in the Hyperlink tab.
- Select OK and Save Content And Close. Save, Preview and Publish your page when you're ready.
Sample code snippets
The following snippets show you how to build a template for your RSS feed. You may have to build a few field templates to render data as you want to, and you can play around with what fields are displayed using the Template part dropdown menu.
Body top template
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>City of Point Russell News Feed</title>
<language>en</language>
<link>http://pointrussell.opencities.com/feed.rss?listname=News%20RSS%20feed</link>
<description>City of Point Russell News</description>
<generator>City of Point Russell News</generator>
<managingEditor>team@opencities.com</managingEditor>
<webMaster>team@opencities.com</webMaster>
<atom:link href="http://pointrussell.opencities.com/feed.rss?listname=News%20RSS%20feed" rel="self" type="application/rss+xml" />
Item template
<item>
<title><![CDATA[<ItemData DataDefinition="OC Title" Template="OC Name If Empty" />]]></title>
<link><![CDATA[<ItemData DataDefinition="Link" Template="default" />]]></link>
<guid><![CDATA[<ItemData DataDefinition="Link" Template="default" />]]></guid>
<pubDate><ItemData DataDefinition="Activate Date" Template="RSS date" /></pubDate>
<description><![CDATA[<ItemData DataDefinition="OC Short Description" Template="default" />]]></description>
</item>
Body bottom template
</channel>
</rss>