Skip to content

Create templates items for rendering variant?

Creating templates for rendering variants in Sitecore Experience Accelerator (SXA) involves creating a data template that defines the fields that the rendering will display, and then creating a rendering variant that specifies how these fields will be outputted in HTML. Here’s a step-by-step guide:

Step 1: Create a Data Template

  1. Open the Content Editor in Sitecore.
  2. Navigate to the Templates section of your site. The path will be something like `/sitecore/templates/{Your Tenant}/{Your Site}`.
  3. In the Home tab of the Content Editor ribbon, click `Insert` > `Template` to create a new template.
  4. Enter a name for the template and click `OK`.
  5. With the new template selected, in the Builder tab of the Content Editor ribbon, click `Add Section` to add a new section to the template.
  6. Enter a name for the section and click `OK`.
  7. With the section selected, click `Add Field` to add a new field to the section.
  8. Enter a name for the field, select a type, and click `OK`.
  9. Repeat steps 7 and 8 to add any additional fields that you need.

Step 2: Create a Rendering Variant

  1. Navigate to your site’s rendering variants. The path will be something like `/sitecore/content/{Your Tenant}/{Your Site}/Presentation/Rendering Variants`.
  2. Select the rendering for which you want to create a variant.
  3. In the Home tab of the Content Editor ribbon, click `Insert` > `Rendering Variant Definition` to create a new variant.
  4. Enter a name for the variant and click `OK`.
  5. Right-click on the variant and select `Insert` > `Variant Field`.
  6. Enter the name of one of the fields from your template in the Field Name property of the Variant Field.
  7. Repeat steps 5 and 6 to add any additional fields that you need.

Now, you can create items using your new template, and when you display these items using the rendering, you can select your new variant to control how the fields are displayed. The variant will output the fields in the order that they are listed under the variant, and you can control the HTML markup around each field by setting the Tag property on the Variant Field.

Share this post on social!

Leave a Reply

Your email address will not be published. Required fields are marked *