codeflood logo

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.

feed designer

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.

rss on page

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.

content rss feed

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 android

Sitecore workflow RSS on an Android phone - Article view.

sitecore workflow rss android article

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).

Sitecore workflow RSS in Akregator

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.

Comments

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

Anonymous

Hey man, some of your tag links point to "en.wordpress.com" instead of your blog.

Alistair Deneys

Thanks Guys. Anon, which links did you find pointing to en.wordpress.com?

Alistair - awesome article, I think it is fair to say that the template filtering should have been in the core product.

I'm trying to create a customized RSS Feed template like you detail above but I cannot get it to work. I constantly get an error indicating that my template must inherit from Sitecore.Syndication.PublicFeed (which it is).
What is the trick to getting these wired up?

Alistair Deneys

Hi Kyle, No tricks from memory. I would expect the most likely cause of that issue is if the .net type specified in the "type" field of the RSS content item is incorrect. Double check and make sure it is fully qualified in "namespace.class,assembly" format such as "Project.Feeds.CustomFeed,Project".

Ah, now I see my issue. I was only using the fully qualified name but not including the assembly. I should have thought of that. Thank you for solving what has been an annoying issue preventing me from continuing.

Dennis Sheppard

I've created an RSS Feed that works beautifully in preview mode within Sitecore. But after saving and publishing, my feed is empty on the site.
I can't figure out why preview mode would work great, but the real thing doesn't.
Any ideas? Thanks!

Alistair Deneys

Are the items you're expecting in the feed published? If they weren't that would explain why your feed works in preview and not on the website.

Dennis Sheppard

The items were published.
I ended up opening a ticket with Sitecore about this.
Turns out the problem was that I had presentation settings defined on the template of the items rather than the standard value of the template of the items.
I'm not sure why this caused the items not to show up in the RSS feed, but still be okay in preview mode. I don't know if this is by design or a bug/undocumented feature.

This new functionality is fantastic!
However, do you know of a way to put the same functionality into an email?
Using Sitecore 6.4.1
Ellis Benus

James Walford

How about customised client RSS? I'm interested in an item state RSS for items not attached to a workflow, and maybe filtering information in an workflow RSS for items that do have one.

Alistair Deneys

Hi Ellis, Do you mean allowing users to subscribe to your site via email and getting daily emails of items that have been updated? There are a few ways you could do that. Probably one of the easiest would be to leverage the RSS item. If you've already created the RSS item to service users wanting to subscribe through RSS then it wouldn't be too hard to extend this and write something that allowed users to subscribe to the feed, then have a daily scheduled task that ran and hit the RSS item to find the item's to include in the daily email and shoot it off. You could also make use of the HistoryEngine to find all content that changed over a certain period. The HistoryEngine includes all items so you'd need to filter it to only include the pages that were desirable.
Alistair

Alistair Deneys

Hi James, I haven't looked into customising the client RSS feeds that can be found in the workbox. If you're only after a particular state you can subscribe to that specific state rather than the entire workflow. Just click the RSS icon on the state. Or where you talking about filtering on some kind of field value? Would be an interesting post to see if I could get it working...

Leave a comment

All fields are required.