This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Blogs » Harry Oosterveen » An alternative approach to RSS exports


An alternative approach to RSS exports

Thursday 04 October 2012 1:03:30 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The standard eZ Publish RSS export works, you can relatively easy set up an RSS export. But you have to set up each RSS export manually, which can become cumbersome if you have a large number of RSS feeds to export.

I recall from discussions on the forum (could not find them back, there are just to many hits with RSS), and perhaps there are extensions implementing this already, to use the template mechanism to create RSS feeds, just like you create any view in eZ Publish.

This alternative approach uses a lists of prefered attributes to create each field in an RSS item from the selected objects. This gives a flexible way of creating RSS exports, so you can easily create multiple RSS feeds. This is demonstrated in a project to create RSS feeds based on tags given using the eZ Tags extension.

In the standard eZ Publish RSS export, you create an RSS feed by selecting the top node, and adding the class types that are to be included in the feed. But for each class type, you have to specify which attribute to map to the title, description, category, etc. fields of the RSS feeds.

You will find that most class types use the same attribute for the same field in the RSS feed. For the item title, it is usually the attribute title, short_title, or name, for the item description it is usually intro, or description.

To simplify the creation of RSS feeds, I have taken the object name as title for an item, and the attributes that are mapped to the description, content and categories are read from a configuration file, see below.

# field used for description, in order of preference
# field used for content, in order of preference
# image used for category, in order of preference

So to find the description of an RSS item, the datamap of each object is checked. With this configuration, if the object has an intro attribute, that is used as the RSS item description. If there is no intro attribute, it checks for short_description, and otherwise description.

Similarly, to find the content field, it checks for the existence of a body item. For the category field, it first checks for a tags field, then for a keywords field.

Now that the object attributes are mapped to the item fields, one can create the RSS feed. In the eztagfeed extension, I have used the eZComponents ezcFeed class. 

Having all this in place, all that is left is a mechanism to select objects or nodes for the RSS feed, based on the URL, and we have a new RSS feed. There are methods in the eZContentObjectTreeNode class to select items from the subtree. This approach was developed because I wanted to create an RSS feed based on tags given to objects, so it uses the getRelatedObjects methods in eZTagsObject. After some filtering and sorting, the approach described above is applied to create feeds based on any tag used.

Proudly Developed with from