Wednesday, 30 August 2017

Sitecore SXA Rendering Variants

Many Sitecore SXA components provide functionality to extend the scope of the component and cater for different scenarios.
This flexibility can be achieved by using Rendering Variants.
We can see the rendering variants for all the SXA rendering under location:
/sitecore/content/Tenant/Site/Presentation/Rendering Variants

This blog post will talk about a few things that can be achieved using Rendering variants.
I am taking an example of SXA Page List component.

We already have few pages in our site and we have dragged the page list component into main at Home page:

Above image is showing default page list component with a Title field of all child pages under Home.

Now, if we need to modify this list to include any other information like content from the pages or any other field, we can create our custom rendering variant and add a Variant field to it.
This can be simply done by creating a new Variant definition under:
/sitecore/content/Tenant/Site/Presentation/Rendering Variants/Page List

  •          Right click on “Page List” and click insert “Variant Definition”
  •          Give a suitable name. (Example: “Custom Variant”)
  •          Then right click on “Custom Variant” and add insert 2 variant fields:
  • Important note: The name of the Variant Field should be a name of a field on the item.
  •          We can style the above 2 fields within the variant field item under “Variant Details” Section.
  • After adding the above rendering variant when we now see the Home page in experience editor:
  •          We have the Custom Variant in the drop down to pick.
  •          After selecting it we see the list now has some Content as well, which is coming from the “Content” field of the item.

That’s all for this post.

No comments:

Post a Comment