Kentico CMS 7.0 Developer's Guide

Syndication transformations

Syndication transformations

Previous topic Next topic Mail us feedback on this topic!  

Syndication transformations

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Use of transformations is of the highest importance when creating feeds, as all syndication web parts render the feeds using them. They need to be set in the Transformation property of each feed web part.

 

Default transformations

 

All document types in Kentico CMS have the RSSItem and AtomItem transformations. When you create a new document type, these transformations are created for it automatically.

 

devguide_clip1016

 

The default RSS, Atom and XML transformations can also be generated when editing or creating transformations of a document type or a custom table. To do this, you only need to select the required format from the Code drop-down list and click the Generate default transformation button.

 

devguide_clip1015

 

RSS transformations document type

 

Other feed transformations are found in a special document type called RSS transformations (CMS.RSSTransformations). This is a special document type used just to store transformations for Kentico CMS objects. Transformations for blog comments, board messages, forum posts, media library files and products are contained in the document type.

 

devguide_clip1014

 

CDATA in feed transformations

 

If you need to include CDATA sections in your feeds, you may utilize the EvalCDATA method. This method works in a similar manner as the commonly used Eval method. The difference is that the retrieved string is wrapped in a CDATA section and all occurences of the ]]> character sequence in the string are escaped.

 

Escaping is performed the way that each occurrence of ]]> is replaced with ]]]]><!CDATA[> and the whole text is then wrapped in standard <![CDATA["wrapped text"]]> enclosure.

 

The method has two overrides:

 

EvalCDATA("FieldName") - the first one has only one parameter - the actual name of the retrieved field.

EvalCDATA("FieldName", true) - the second override has one extra boolean parameter, which determines if the wrapping will be performed. If the second parameter is set to false, value of the field will be retrieved, escaping of the ]]> sequence will be performed, but the whole retrieved text will not be wrapped in the standard <![CDATA["wrapped text"]]> enclosure.

 

The second override with the second parameter set to false is particularly useful if you use the method within another CDATA section. Because nesting of CDATA sections is not possible, you will only want to have the retrieved string escaped, but not wrapped in the enclosure. The code example below is a transformation extract where the method is used exactly this way.

 

...

 

<description>

 <![CDATA[

   <strong><%# EvalCDATA("CommentUserName",false) %></strong><br /><%# EvalCDATA("CommentText",false) %>

 ]]>

</description>

 

...