Data sources

Abstract

Learn more about how renderings relate to data source items.

SXA comes with a library of predefined renderings to ensure modular component based design. Most SXA renderings are designed for reusability and pull data from data source items. This means that the content they display is not bound to the page on which they appear but is stored in data source items. When you add a rendering to a page, in the Associated Content dialog you can select an existing or create a new data source item.

The following fields determine how a rendering relates to its data source item:

  • Datasource Location – specify where the user is allowed to look for the data source.

  • Datasource Template – specify the types of data sources users can create.

  • Data source – specifies a data source item.

This topic describes how SXA renderings, depending on how they use data source items.

Note

When building a new rendering, the Sitecore developer must decide which category a new custom rendering falls into, so the rendering can be properly configured.

Renderings without data source items do not store their own data, for example, the Navigation and Breadcrumb renderings. They are static and not editable by content authors.

Field

Value

Datasource Location

Leave empty.

Datasource Template

Leave empty.

Data source

Leave empty.

By default, renderings with an optional data source item read data from the current page, but can be set to read information from the data source item instead. For example, the Title, Subtitle, and Content renderings.

Field

Value

Datasource Location

Leave empty

Datasource Template

Leave empty

Data source

Leave empty or reference a data source item

Renderings with a single data source item always use one data source that is unique for a specific platform, tenant, or site. For example, the Cookie Warning and Promo renderings.

Field

Value

Datasource Location

Leave empty

Datasource Template

Leave empty

Data source

Data source item reference

Renderings with a reusable data source enable the content editor to create and/or select a data source item. For example, the Accordion, Carousel, and Video renderings.

Field

Value

Datasource Location

Reference to the item that groups rendering data source items.

Datasource Template

Reference to the data source item template.

Data source

Leave empty.

58F7EFB4774F478582B80016960DCCD1.png

Note

To select additional templates, navigate to the rendering sitecore/Layout/Renderings/Feature/rendering group/rendering and in the Experience Accelerator section, in the Additional compatible templates field, click the template and click the right arrow to move it to the list of selected templates.

Renderings that can use content from the current page have an option to select the page as a data source. When the Can select Page as a data source box is selected, it lets you use a page as a data source. This option is available for renderings that take content from the current page such as Page Content, Page List, JSON content, and JSON list.

For example, navigate to sitecore/Layout/Renderings/Feature/JSON/JSON Content and in the Experience Accelerator section select the Can select Page as a data source option.

CDC054E0D6E3463BB06F9F0F08813E83.png

Renderings with an automatically generated data source store data and create the data source item when a content editor places the rendering on the page. For example, the Rich Text, Image, and Plain HTML renderings.

Field

Value

Datasource Location

Reference to the item that groups rendering data source items.

Datasource Template

Reference to the data source item template.

Data source

Leave empty.

Additional setup

SXA automatically generates data items for white-listed folder templates. Therefore, the grouping item (Datasource Location) must be of a named type and this name must be added to the configuration:

<experienceAccelerator>
      <!-- List of renderings for which a data source is automatically created after adding that rendering to a page. -->
      <autoDatasourceRenderings>
        <rendering name="Image">{4A0D4E0B-BC20-4F2E-BD84-A4BD35834E86}</rendering>
      </autoDatasourceRenderings>
    </experienceAccelerator>

Administrators can configure the behavior of non-reusable components in the Editing section of the Settings item (/sitecore/content/TENANT_GROUP/TENANT/SITE/Settings) by selecting one of the following options:

  • Auto-generate name and store item under site data – a new data source item is created with an auto-generated name and is stored in the location shared across the entire site.

  • Auto-generate name and store item under current page – a new data source item is created with an auto-generated name and is stored as a page relative data source item under a given page.

  • Prompt user for name and store item under site data – the author is prompted to provide a name for the new data source item, which is stored in the location shared across the entire site.

  • Prompt user for name and store item under current page – the author is prompted to provide a name for the new data source item, which is stored as a page relative data source item under a given page.

2608990873DA4B0C89EA11DACFC2BD05.png