Search
Filtered RSS feed using the Sitecore rules engine
I recently had a need to create a custom RSS feed in Sitecore that could dynamically exclude certain items from the feed.
My first thought was to simply use a Sitecore query in the feed item's "Items" field, as the field allows you to either specify a root item whose descendants will be included in the feed or use Sitecore query to specify which items will be included in the feed. This seemed like a valid approach until I started writing the query and it quickly turned into a garbled mess - I'm not a fan of complex xpath queries. On top of that, I could never expect an average content author to understand the Sitecore query syntax or maintain a complex query.
I thought "it would be nice if an average content author could use an intuitive, somewhat familiar interface to specify the logic that should be used to exclude items from the RSS feed". Enter the Sitecore rules engine and the Rules field type. By creating a custom RSS feed template, adding a Rules field and extending the standard Sitecore RSS feed class, this turned out to be a pretty easy task.
Create a new RSS feed template
Create a new template that inherits the "/sitecore/templates/system/feeds/RSS Feed" template. It's important that this inheritance occurs otherwise the standard Sitecore RSS feed rendering will not work and you would need to roll your own feed manager (let's try to avoid that).
With your new template created, add a field of type "Rules". I named the field "Exclude Item Rules" but feel free to rename to suit your needs.

