Reputation: 713
I'm trying to get Sitecore to create a new item before the "Select Datasource" dialog that opens from the Page Editor when a new rendering is added to the page.
we are building a multi site solution where each site is represented like this (conceptual)
site1 (template = website)
Datasources (template = datasourcefolder)
Module X Sources (template = module1container)
Module Source 1 (template = module1)
Module Y Sources (template = module2container)
...
Home (template = startpage)
The sites will be created using a branch template that will create the items based on templates website, datasourcefolder and startpage.
Here's what I want to happen:
When a new sublayout is added, check if the source exists, if not, create a new item in site1/Datasources/[Module name] based on a specified template (defined as Parent Datasource Template and added to the Sublayout template). Then add this new item to the dialog DatasourceRoots to allow the user to create datasource items below it.
I've successfully implemented a pipeline to check for, and create the item if it doesn't exist and the Select rendering datasource dialog shows the newly created item and allows the user to create a new datasource item below it, just as expected. However, after clicking OK, an alert is show with the message "An error occurred". Closing this dialog and performing the operation again (when the datasource root already exists) works just fine.
Using Reflector I have verified that the item created from the dialog (Sitecore.Shell.Applications.Dialogs.SelectRenderingDatasourceForm) is returned properly and the dialog is closed with the correct arguments and a SetDialogValue call with the exepected item.
I guess my question is; what happens AFTER this dialog is closed? What pipeline is triggered to actually set the datasource on the rendering? I need to figure out where this error is raised and, of course, fix whatever is wrong...
I realize this might be a bit hard to understand, I'll gladly provide the code if needed.
Upvotes: 2
Views: 675
Reputation: 6890
We do something very similar, but as a child of the current item. Reference the code here:
I would ensure you are using a SiteContextSwitcher when creating the item. Otherwise event handlers in place for the PageEditor could have unknown side-effects. Some of these event handlers are created in code by Sitecore, and can't be disabled in config.
Upvotes: 1
Reputation: 8877
I think that it's an event that is causing the error, not a pipeline processor. Probably an OnItemSaving event.
By default, Sitecore has configured Sitecore.Tasks.ItemEventHandler.OnItemSaving
to be executed when an item is being saved.
Upvotes: 0