Transformations

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

The functionality of transformations is very similar to that of templates used by standard ASP.NET list controls such as the Repeater. The main difference is that our transformations are stored separately in the database and can easily be used repeatedly. They can be assigned to listing web parts or controls through the appropriate Transformation properties.

 

The code of transformations depends on their type. ASCX transformations are the most common, they can contain a mix of HTML elements, embedded controls, standard ASP.NET data binding expressions and methods, such as Eval(), and special methods designed to be used in transformations. XSLT type transformations need to be in valid XML format and can contain standard XSL elements.
 

The use of transformations is supported by all web parts that can display document data, as well as by those listing controls that are designed to work directly with Kentico CMS documents.

 

Transformations are categorized under the document types that they are supposed to display. They can be managed in the Kentico CMS administration interface at Site Manager -> Development -> Document types -> ... Edit document type ... -> Transformations. Some document types do not represent an object but serve only as a container for transformations and queries.

 

The full name used to identify transformations uses the following format: <document type code name>.<transformation name>

 

The sample sites include many transformations for all document types and you can modify them or write new transformations to suit any of your requirements.
 

Example

 

The code of the Ecommerce.Transformations.Product_SimplePreview ASCX transformation, which is used to display key information about products, looks like this:

 

<div class="ProductPreview">

<div class="ProductBox">

  <div class="ProductImage">

      <%# EcommerceFunctions.GetProductImage(Eval("SKUImagePath"), 140, Eval("SKUName")) %>

  </div>

  <div class="ProductTitle">

      <%# HTMLEncode(ResHelper.LocalizeString(Convert.ToString(Eval("SKUName")))) %>

  </div>

  <table class="ProductPrice" cellpadding="0" cellspacing="0">

  <tr>

      <td class="left">Our price:&nbsp;</td>

      <td class="right"><%# EcommerceFunctions.GetFormatedPrice(Eval("SKUPrice"), Eval("SKUDepartmentID")) %></td>

  </tr>

  </table>

</div>

</div>

 

When this transformation is assigned to a listing web part or control that has products (SKUs) in its data source, the output code of individual products will contain the values returned by the methods and data binding expressions, like the following example:

 

<div class="ProductPreview">

<div class="ProductBox">

  <div class="ProductImage">

      <img alt="Samsung SGH E250" src="/KenticoCMS_FilterTest/getmetafile/da2495b2-ff5f-47cb-b463-4b99d308eadd/CELL_SAMSUNG_SGH_E250.aspx?maxSideSize=140" border="0" />

  </div>

  <div class="ProductTitle">

       Samsung SGH E250

  </div>

  <table class="ProductPrice" cellpadding="0" cellspacing="0">

    <tr>

      <td class="left">Our price:&nbsp;</td>

      <td class="right">$249.00</td>

    </tr>

  </table>

</div>

</div>

 

The final output of this product on the website will then look like this:

 

devguide_clip1332

 

 

 

Please note

 

The CSS stylesheet used by the page or site is applied to the output of the transformation. This example uses the default Corporate Site stylesheet.

 

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?document_types_transformations.htm