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.

Wednesday, 16 August 2017

Remove Inline Styling on Sitecore SXA image component

This post describes one of the basic issues we face while using some of the Out of the box SXA components.
The Image component when dragged and dropped from the toolbox, straight away adds the following HTML:

 Here we can see that an inline style is added to the image tag, which overrides the image margin supplied by the Front end team(agency).
This can be an issue where every image of the site has a forceful margin set to it as 0px 0px.

This inline style is getting added from a SXA class called "SetImageStyleParameters", which can be found under: Sitecore.XA.Foundation.SitecoreExtensions.Pipelines.RenderField.

We can find this class patched in : ~\Website\App_Config\Include\Foundation\Sitecore.XA.Foundation.SitecoreExtensions.config
As :

 We can simply get rid of the inline style by removing the patch from "Sitecore.XA.Foundation.SitecoreExtensions.config" or we can override the process based on our custom requirements.

Sunday, 13 August 2017

Creating and adding Datasource for custom Sitecore SXA rendering in experience editor

         Now that we have dragged and dropped our custom carousel in previous blog post, we can’t see an option to create datasource on the fly (i.e in experience editor mode) like we see for other SXA renderings.
    To achieve that we need to add some custom buttons(Edit frame buttons) on the experience editor component panel.

         We can achieve that by following steps:

Step 1: Creating edit frame buttons:
o   Switch to core DB in Sitecore

o   Create 2 folders for showing button to add a carousel item & other folder for adding carousel slides

o   We can add above buttons by copying from the existing buttons in the OOB carousel/any other component folder.

Note we can make editing the template fields for the carousel even easier by adding pipe separated field names in the edit item: