Contents
How to create complex rendering variants in CSS?
To create complex rendering variants, with CSS classes defined in rendering parameters resulted in an overuse of the rule definitions and, I must admin, duplicating a lot of items. Now from Sitecore 9.3, we have access to a scripting item called “Scriban”, which can easily replace a part or the whole rendering variant for a component.
How to execute a rendering variant in sxa?
Renders a dynamic placeholder with optional context switch. Executes a rendering variant field located beneath the Scriban template. Evaluates the rendering variant rule stored beneath the Scriban template and returns the evaluated value (true or false) based on the result of the rule execution.
How to replace a rendering variant in Sitecore 9.3?
Now from Sitecore 9.3, we have access to a scripting item called “Scriban”, which can easily replace a part or the whole rendering variant for a component. Scriban is easily extended, fast and powerful.
Which is an example of a scriban rendering?
Scriban is easily extended, fast and powerful. Our first example is to create a new variant rendering for the Promo item. The promo item contains 6 fields: Promotext, promoIcon, PromoLink, PromoText2, PromoText3 and PromoIcon2.
Why are rendering variants so difficult in sxa?
When creating my own rendering variants in SXA, I was often frustrated by the rigidity of the elements available to create the variant’s HTML structure. For example, it was nearly impossible to render easily the value of a Droplist or taking care of rendering parameters.
Are there rendering variants in Sitecore Commerce renderings?
Unlike many of the SXA renderings, Commerce renderings don’t support rendering variants. There are however two exceptions. Those being Product Bundles and the Product Information Page Content variant. This doesn’t offer a lot of flexibility for multiple site instances, especially if each site wants a different look and feel for the product page.
Where are the variant fields located in Sitecore?
This model includes the VariantsFields property which holds the variant definition configured in Sitecore. It’s possible you may be able to get by with just implementing this field on your rendering model and populating it yourself.
Can you use multiple rendering variants in sxa?
Rendering variants within SXA allow you to define your own html structures that will render your field values. You can use multiple variants to render the exact same content in a completely different way. In this post I will not explain how to use rendering variants or build your own.
How to set a variant field as a data attribute?
The way to do that is to use tokens within the data attributes of a variant field. In our case we want to define a style element on our div element which will contain the background-image. In the data attributes we set style as the key and for the value we will use “background-image: url ($ (PromoImage)”.