4
votes

Before digging into my explanation i will summarize my question:

How do I provide the user (editor) with a user-friendly possibility to select a datasource item for sublayouts that are preset on the standard values?

My situation is as follows:

I have a page template, with pre-defined layout on the standard values. Let's say the layout consists of:

  • one placeholder "wrapper"
  • one sublayout "content"

This sublayout is pre-defined on my page template, but can also be placed in the placeholder using the Page Editor. It needs to have a datasource item that defines a Title and Body value.

Now, if a user adds this sublayout to the placeholder using the Page Editor, he will get a nice interface to select or create the datasource item (see screenshot).

enter image description here

However, if the sublayout was pre-defined on the standard values, it will be added without datasource (I can't pre-set the data source in the standard values because it's still unknown by then).

At that point there seems to be no way to get to that nice interface for selecting or creating a datasource item.

Ideally I want to be able to add a field to my template that can hold a datasource item which the user can select/create using the nice interface. I looked at the datasource field type, which could be an alternative, but it's still not exactly what I want.

Bare in mind that the content sublayout is just an example. I understand that in that specific case I could solve it by always adding a title/body field to the template which hold the values if there is no datasource, but for my real world problem that won't suffice.

I don't have a whole lot of experience with the Page Editor (with the new way of working with it) so I would like to get some advice on this subject.

1
Just trying to understand the scenario .. Do you want the datasource select dialog to appear when the page is created ? - Stephen Pope
That would be perfect! Wouldn't it be great to be able to define on a sublayout that it requires a datasource item in order to be used and that Sitecore would display the Datasource Wizard upon item creation. And also.. it would need to show that same wizard in the Page Editor if the editor tries to modify the datasource (now it shows just the internal link editor in that case). - Ruud van Falier
I think the problem is that the pop-up could be for any component on the page .. (so potentially you could end up with a silly amount of pop-ups on a page with a lot of components!) - Stephen Pope

1 Answers

5
votes

According to what you said here:

Ideally I want to be able to add a field to my template that can hold a datasource item which the user can select/create using the nice interface. I looked at the datasource field type, which could be an alternative, but it's still not exactly what I want.

It seems you want an intuitive data source selector interface in the CMS shell similar to the Page Editor-based UI.

Quick answer: Simply put, there's nothing that does this for you in Sitecore.

Longer answer: There are still some options for you, e.g.

Define a global "dummy" data source and set that to be the data source set in in Presentation > Layout Details of the template's standard values. So every time you create a new page, it will always point to that dummy value to show something.

From here you can do a few things:

  1. If the user must use the shell UI and not Page Editor, they can simply create another data source item for the specific page and update that page to point to it using the existing native interface in Layout Details.
  2. Another option is to write an event handler, say for item:created or similar that when you create an item, auto-create a corresponding data source item for this specific page (whether this auto-created item be a sub-items or global item...) then programmatically set this to be the data source. A similar concept is shown in this video by Nick Wesselman: http://www.techphoria414.com/Blog/2012/May/Sitecore_Page_Editor_Unleashed