Create a custom module in SXA 9.3

9/3/2020 Sitecore-9 Sitecore-sxa

Create a custom module in SXA 9.3

Here we are trying to create a hero banner component in Sitecore SXA.

Create a module under : /sitecore/system/Settings/Feature/Tenant A/Site A

Where Tenant A and Site A are the names I used for testing purposes. You can create folder structure that suits your business needs,

Create module SXA

Clone a rendering. Cloning in SXA is not Sitecore traditional cloning but means copy and recreate renderings parameters, data sources, and updating their references.

Here I am cloning the Promo component to create a Hero Banner component.

Go to the promo component : /sitecore/layout/Renderings/Feature/Experience Accelerator/Page Content/Promo

Right-click on the item use > Scripts > Clone Rendering

Clone-Rendering-General

Update Name, folder path and rendering class name accordingly

Rendering Parameters and Datasource tabs have two options:

  • Make a copy of original rendering parameters
  • Inherit from existing rendering parameters

Its always advisable to make a copy rather than using the existing one.

 

On the View tab you have options:

  • To use the original MVC view file
  • Copy MVC view file
  • Select an existing MVC view file

Always better to go with Copy MVC view file, so you not changing Sitecore related views

Clone rendering view

Update the rendering view path to your needs, i used HeroBanner.cshtml

This creates templates in : /sitecore/templates/Feature/Tenant A/Site A/Hero Banner/Hero Banner

Remove all the fields that are copied from Promo component and add necessary for HeroBanner

HeroBannerTemplate

A Branch template would have been created by now under: /sitecore/templates/Branches/Feature/Tenant A/Site A/Hero Banner

Remove the default rendering variant which is for Promo one, create a scriban for Hero Banner.

HeroBannerScriban

Go back to the settings section of hero banner and update the toolbox section name oni Name field in :/sitecore/system/Settings/Feature/Tenant A/Site A/Hero Banner/Hero Banner Site Setup/Add Available Renderings/ I used Tenant A Custom Components

Now go back to the Site and add this module. Right-click on the site > Add Site Module.

 

This will create Hero banner folders in: 

  • Data 
  • Presentation

 

Finally we can see the module we created in the Experience editor toolbox

Finally we can see the module we created in the Experience editor toolbox

Happy Sitecoring!!!

Let me know of any questions.