Sitecore 6.2 RSS
When Sitecore 6.2 was released I wrote a post about some of the new features included in the release. One of which was inbuilt RSS. I think this feature was quite underplayed on my part, so allow me to make a song and dance about it here.
The RSS capabilities of Sitecore 6.2 comes in 2 parts. The first is standard content RSS. It's now quite easy for content authors to create RSS feeds for their content. The Shared Source RSS module always allowed us to do that but now it's handled natively. The RSS module is also quite old and had to provide it's own way of doing certain things that have since been added or changed in the CMS.
Content RSS feeds in Sitecore 6.2 are very easy to create and have been designed to allow non-developers to create and maintain them. There are 2 parts to creating a content feed. Firstly you have to define the appearance of the feed; which data fills in which RSS element. This is done using the feed designer form which sits on the presentation tab in the content editor. The feed design is saved back to the item's template standard values so all items based on the same template will look the same. After all, you don't want to have to go through every single item and define it's feed presentation.
The feed designer presents a selection of fields you can use to populate each of the RSS elements. And this would be fine for most content authors. But what if you need to create a more complex aggregation? What if you want to generate the body of the feed based on several fields, or even refer to other items as well? All the feed designer is doing is setting a presentation for the RSS device of the item's template standard values. This is the same way in which you'd define presentation for any other kind of device. You'll notice after you've designed the feed that the feed device now uses the "Feed Delivery Layout" layout and the FeedRenderer control. Being that this is standard presentation definition you could change this if you needed more flexibility in designing the feed.
After we've designed the item's feed presentation we need to define a feed item which when requested will output the RSS. This is as simple as creating an item in the content tree which inherits from the /sitecore/templates/system/feeds/rss feed
template. You'll need to fill in the items
field which points to the parent of the items you want to syndicate through the feed.
If we need more control over the behavior of how the feed works we can also specify a custom type in the type
field of the feed item to override these default behaviors. This custom feed type must inherit from Sitecore.Syndication.PublicFeed.
Let's say I wanted to be able to filter based on template, so only items that are based on certain templates will be included in the feed. I would first create a new template which inherits from the rss feed
template and add an additional field Include Templates
of type TreeList to my new template. I could then use the following class in the type field of a feed created from that template to perform the filtering.
using System.Collections.Generic;
using System.Linq;
namespace Sitecore_Custom_Feed
{
public class CustomFeed : Sitecore.Syndication.PublicFeed
{
public override IEnumerable<Sitecore.Data.Items.Item>
GetSourceItems()
{
string templateIDs = FeedItem["Include Templates"];
var items = base.GetSourceItems();
return items.Where(i => templateIDs.Contains(
i.TemplateID.ToString()));
}
}
}
Now only items which are based on any of the templates in the Include Templates
field will be included in the feed.
Another handy extension to have on each page is the ability to check if an item contains a feed item as a child and provide the alternate link tags in the html head to have the browser detect the feed for this page. Firefox for example will display an RSS icon on the right-hand side of the address bar if the page contains an alternate link.
Some XSLT you might use to output that tag:
<xsl:for-each select="child::item[@template='rss feed']">
<link rel="alternate" type="application/rss+xml"
href="{sc:path(.)}" title="RSS feed"/>
</xsl:for-each>
Just make sure your alt link rendering is included in the head section of your HTML.
Content authors can also simply link to the feed item after they've created it in the rich text editor.
After publishing your changes you'll be able to see the feed on the live website.
The second part of the new RSS capabilities in Sitecore 6.2 is Sitecore Client Feeds. Sitecore now allows you to subscribe via RSS to a workflow, workflow state or individual content item's updates. This is really awesome cause it means content approvers no longer have to log into Sitecore each day to check their workbox. All the information they would have received from this application is available through RSS, including the ability to execute commands directly from the RSS.
Lars Nielsen noted in a comment on my original Sitecore 6.2 new features post that he has subscribed to workflow using Outlook. I've also heard other people calling this client feeds capability "Outlook integration for workflow". This is a misnomer. Calling this feature as such is actually limiting it's potential. RSS is more pervasive than just Outlook and Windows. With this capability I can now have native support for workflow information using any RSS program on any platform (or device :) ). I can approve articles directly from my Linux machine (Sitecore supports the content editor cross browser, so I could have already done that, but now I'm using a native application), or from my mobile phone. Anything that can support RSS.
I'm actually quite disappointed in the workflow RSS capability. Why you might ask? Does it lack a particular feature? Does it lack some polish? Do I not like how it works? No. None of the above. Earlier this year I achieved a very similar result using email. Actually I should say it was one of my colleagues as it was he who wrote the thing (thanks Michael!). The basic idea of the Next Digital extended workflow action was to provide an email action that can be included in workflow and provide both extended capabilities in terms of field data and provide workflow commands inside the email. This action was based on Alexey Rusakov's extended email action. So I'm quite disappointed in the workflow RSS capability because our really cool Sitecore extension is not as unique as it once was.
To subscribe to a workflow feed simply log into Sitecore and open the workbox then click on any of the RSS icons in the UI. The RSS icon in the workflow title bar is of course for the entire workflow and the RSS icon in the title of each workflow state is of course just for that state.
Now whenever an item enters the state (for state RSS) or when it changes state (for workflow RSS) you'll get a notification in your RSS client. You'll get a bunch of information about the item along with the available commands you can execute against the item, taking into account your security. This means that if you don't have the required permissions to the command, you will not see the command in the feed.
And just to prove it really does work outside of Outlook, here's a few other programs and platforms.
Sitecore workflow RSS on an Android phone - List view.
Sitecore workflow RSS on an Android phone - Article view.
Can you imagine as a content approver being able to approve content whilst on the run straight from your mobile phone?
Sitecore workflow RSS in Akregator in Kubuntu (Linux).
For more information on RSS feeds in Sitecore 6.2 and for full instructions on how to create them, refer to the Content Author's Reference and Cookbook for Sitecore 6.2 which can be downloaded from the SDN.
As always, Alistair, you get the point straight away.
Mobile device approving is one of the major reasons we implemented this functionality. Great article.
Best, Lars