Data sources

Current version: 1.7

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.

No data source item

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.

Optional data source item

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

Single data source item per platform/tenant/site

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

Reusable data source

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.

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.

Select Page as a data source

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.

Auto-generated data source

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:

RequestResponse
<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.

Do you have some feedback for us?

If you have suggestions for improving this article,