From what I can tell, rendering variants are a way to support alternate presentations of a single component. What are the benefits of rendering variants over creating a custom rendering parameters template for a regular controller rendering?
2 Answers
Rendering Variants allow you to define and control the actual HTML structure, rendered by the component, from within Content Editor. You can also use the rules engine to control when certain fields are displayed.
In this example, we modified what was displayed based on the template of the item found in the search results.
I suppose you could do all of this with rendering parameters, but that'd be a lot of parameters and code to write... :)
The benefits of using SXA rendering variants over simple Rendering Parameters.
Rendering variants and rendering parameters are directly related but are different.
Rendering variants give complete complete control over the HTML markup, in case you need to divide the sections in different <div>
tags, add custom CSS classes, to design and give better UI results.
Rendering variants allow to have custom rendering parameters, for example. you want to show the title of the page on a promo, you can use the rendering variant
and assign the rendering parameter to Title
.
Rendering Parameters are the assigned parameter to the renderings,
These are the default rendering parameters for Promo. But we can change it to Title
depending on our logic and requirements.