How to Create custom Rendering in SXA?
Below we will see the steps to create SXA compatible custom rendering and SXA compatibility should have the following features:
- Available in Toolbox.
- Would Support Drag and Drop.
- Will Help Content Authors (with help text and areas where they can insert)
- Multiple Variants.
- SXA Out-of-the-Box (OOTB) Styling.
How to add custom Rendering in Rendering Variants?
First add an Available Renderings item under the Available Renderings folder. In this case, I’ve added one called Cars. Once you’ve added the Available Renderings item, click “Edit” on the Renderings field, and add your new rendering (“Car”) to the list of renderings.
How do I create a car rendering in sxa?
To start off, create a new Variants item called “Car” under the Presentation/Rendering Variants folder of your SXA site. Under that item, create 3 Variant Definition items for each of the variants we need. When the variants have been added, they can be selected from the Variant dropdown list in the Experience Editor:
Where to find available renderings in sxa toolbox?
To make the rendering appear in the toolbox, we need to add it to Available Renderings. The Available Renderings folder is found under the Presentation folder of your SXA site. First add an Available Renderings item under the Available Renderings folder. In this case, I’ve added one called Cars.
How to make a rendering of a car?
The rendering should be a Controller Rendering. Set the Controller (this one has been set to “Car”), and set the Controller Action to “Index”.
Which is the default action result in sxa?
Keep in mind that the controller must inherit from Sitecore.XA.Foundation.Mvc.Controllers.StandardController. The Standard controller will handle the routing with default action result “Index”, so there’s no need to add our own, although we can override “Index” if we need to.