Tailwind Logo

Configuring XM Cloud's Component Wizard - Part 2 Datasource

XM CloudHeadless SXA

Published: 2024-10-04

This time, we will check the Datasource item on the Datasource tab of the Component Wizard.

Confirmation of operation with wizard

First, in creating a component, there is a Datasource section. Here you will see three options.

xmcsxacompwiz09.png
  • Ask user for data source ( Default )
  • User current page
  • Automatically create data source under page

Let's review the differences between these operations.

User current page

Selecting this item reduces the number of items displayed in the dialog in the first place.

xmcsxacompwiz10.png

Also, the Behaviors section is reduced to only two items.

xmcsxacompwiz11.png

If you go to check the Renderings settings of the created component, you will see that the Datasource Template item in the Editor Options is blank.

xmcsxacompwiz12.png

Not only is the above blank, but of course no template has been created for this component.

xmcsxacompwiz13.png

The standard components that do not have a Datasource Template are as follows

  • Navigation
  • Page Content
  • Title
  • Columun Splitter
  • Container
  • Row Splitter

The list shows that Title and Page Content do not require separate definitions because they refer to the item's data, and the other components use information about the site's structure.

We have previously introduced the idea of deleting the Datasource Template when creating the Breadcrumb sample, but in fact, this choice will prevent unnecessary data templates from being generated.

If the component itself has no data, you will find that you can create it with this option.

Automatically create data source under page

Then select the last item, automatically create data source under page, to create the component.

IsAutoDatasourceRendering has been added to the Experience Editor settings for the rendering of the created component, for the other properties.

xmcsxacompwiz14.png

To see how the behavior differs, place the component in the Experience Editor.

xmcsxacompwiz15.png

Above is the component created with Ask user for data source, and below is the component with Automatically create data source under page.

Although the difference is not obvious by itself, when you go to the Experience Editor to view the data, you will see that items are created in the latter as shown below.

xmcsxacompwiz16.png

As the name suggests, this setup creates a Data folder under the page, where the items of the template defined in that component are created.

Of course, adding IsAutoDatasourceRendering to a component created with Ask user for data source will result in the same behavior. The only difference is the initial settings.

Summary

In this case, we have identified different Datasource settings when creating a component. When you do not need to have data (components such as Breadcrumb), you do not create a template using User curret page, and when you create an item in the data folder associated with a page, you set the IsAutoDatasourceRendering setting to automatically create items in the data folder associated with the page.

Tags