0
votes

I've set up a custom page type for my hero banners (all are inside /hero/ folder on the content tree) and used a repeater to display the banners in form of a carousel. The current transformation I have centering all elements (text/buttons) inside all banners. However, in some situation, it looks better if the elements are left or right aligned. Is there a way to use more than one transformations for this kind of thing; even better, is it possible to manually specify which transformation will be applied to which item inside the /hero/ folder.

I noticed there's a field for Alternating transformation; however, looks like Kentico will automatically apply it to the even items. Thanks for your input!

3

3 Answers

3
votes

Probably the easiest way would be to add an extra field (or a couple of fiedls) to a page type, where editor could specify the position of elements or simply type in a class. E.g. drop down with otions right, left and center; each option value could be a class that you just include into your transformation. The rest is just implementation of appropriate CSS classes.

1
votes

If you are using Text/XML transformation then you could also write your inline if conditions like this:

{% if(heroName == "Zeus" || heroName == "Odin"){ %}
<h2>HTML for zeus or odin</h2>
{% } else { %}
<h2>HTML for anyone else </h2>
{% }%}

This documentation might be helpful with regards to macro syntax and expressions.

0
votes

Alternating transformation is used for automatic Odd/Even elements.

In you transofrmation you can use condition and call another transformation. Something like this:

{% CurrentDocument.ApplyTransformation( ([YOURCONDITION] ? "[TRANSFORMATION_A]" : "[TRANFORMATION_B]") ) %}

where [YOURCONDITION] is the condition to test if use TRANSFORMATION_A or TRANSFORMATION_B. The transformation name must contain the entire "path" (example CMS.Root.UsersInText)