July 23, 2024

Dear Sitecore Family,

Yesterday, we saw how selecting a Datasource Location helps the Business User.

Today, lets take it a little further, lets see if we can do something so that the Business User is not confused between selecting the type of Datasource Item for a component, if there are a number of components available at the specified Datasource Location.

Challenge:

Can we make the Business User journey easier while working with Sitecore by specifying the Type of Item that is expected as a Datasource Item by the Presentation Component?

Solution:

Again, the answer is Yes! Thank you Sitecore!

Oh, you want to know how can this be done?

Well, lets check that out.

Quoting an example from the Launch Sitecore 8 Demo Site and again considering the Carousel Component. In every Presentation Component – whether a Rendering or a Sublayout, there is an item field called Datasource Template. [Note: Sitecore as already provided the value for this field in Launch Sitecore site, I have removed it for our understanding purpose, of how things work when this field value is not specified at first and then specified later.]

We will make use of this field, to specify the Type of Datasource expected by the component.

Datasource-Template-Field

By default, for any Presentation Component, this field is empty. So, whenever the Business User tries to set the Datasource from Page Editor, this is what he/she will see.

Select-anyitem-as-datasource

Select-anyitem-as-datasource-2

See that, the Business User can select any item as a Datasource.

Now, lets check what happens when we set the Datasource Template, for the Rendering.

Template-in-Datasource-Template-Field

Datasource-Template-Field-Set

And now checking the Select Associated Content dialog from Page Editor.

Select-anyitem-as-datasource-2

Datasouce-Item-cannot-be-selected-if-type-doesnt-match

Oh Wow!

So this is what happens. Sitecore Validates the item that is selected as a Datasource and if the Datasource Item is not of the Template specified above, it cannot be added as a Datasource.

At the same time, Sitecore gives us a nice validation message for the understanding purpose.

Simple and Useful right?

Hope you enjoyed the post!

Happy Sitecoring! 🙂

Leave a Reply

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