Sitemap
FAUN.dev() 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Sitecore SXA Create a Custom Module/Component via Cloning

4 min readJun 9, 2023

--

Press enter or click to view image in full size

This article will discuss how to create a custom component by cloning an existing SXA component. If you want to use an existing component with more customization, SXA gives the option to clone the default SXA components to make a completely new one.

Create a new module

First, you need to determine in which module it will sit within. If you decided to have a new module for the custom component follow the steps below.

  1. Go to the content editor
  2. Navigate to System → Settings → Feature
  3. Right-click and choose Insert → Module
  4. Provide the Module name
  5. Choose the correct module group (Experience Accelerator folder contains all the default SXA components. It is recommended to choose another folder as the Experience Accelerator folder will get updated with the latest. So you can create a separate folder and add the location to the module group)
  6. Select the system areas that you want to add container folders. Templates, Branches, Settings, and Renderings are always should included. Others are optional.
  7. Choose the Module scaffolding option. Most of cases, it should be Site Setup only.
Press enter or click to view image in full size

Once you proceed, it will scaffold a new module with the name provided and create folders in the required locations. But still, those folders are empty. So as the next step, we need to clone the existing rendering to it.

Clone Rendering

Next step is to clone and copy a rendering.

  1. Go to Layout → Rendering → Feature → Experience Accelerator → Page Content → Promo (whatever the component that you want to clone)
  2. Right click on the component → Scripts → Clone Rendering
  3. In the popup window, fill the required fields.
  4. Under General Tab, please make sure to use a meaningful name for the new rendering name. Point to the module location (It can be a specific location based on your requirement). Provide a suitable rendering CSS class to the required field.
Press enter or click to view image in full size

5. On the second tab, Parameters, you will need to select the rendering parameters as ‘Make a copy of original rendering parameters’.

  • Inherit from existing rendering parameters: This option creates a new rendering parameters that inherits from the original one where as copy just copies all the fields. If you are using the same fields in the new component, you can choose this option.
  • Make a copy of original rendering parameters: If you want to alter parameter fields from the original one, then select this option.

6. On the third tab, please select the data source as ‘Make a copy of original datasource’.

  • Inherit from existing datasource: Same as above two options. If you want to have the same fields and nothing new for the current design, you can pick this option.
  • Make a copy of original datasouce: If you want to alter the fields and have few modifications to the new component, select this option.

7. On the last tab, View field contains three different options to select.

  • Use original MVC view file: Uses the same view. It keeps the same .cshtml file as the original type. We can use this option where we don’t want to change anything in the .cshtml file.
  • Copy MVC view file: You specify the path in the box below and it will copy the cshtml to the path outlined.
  • Select existing MVC view file: Will load an existing cshtml file in the path outlined.

When you good to go, you can click on the clone option.

Get Anjali Nirmani’s stories in your inbox

Join Medium for free to get updates from this writer.

Feel free to share your knowledge or add comments if you have any feedback regarding this post :) Hope to see you again with another interesting topic. Thank you ❤

👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Join FAUN Developer Community & Get Similar Stories in your Inbox Each Week

--

--

Anjali Nirmani
Anjali Nirmani
FAUN.dev() 🐾
FAUN.dev() 🐾