Fixed that default layout data would not be applied.

This fixes the issue where the default layout data string would not be applied when creating new content items of a content type with the LayoutPart attached.
For example, creating new Form content items would start out with an empty canvas instead of with a default Form element and a submit button.
This commit is contained in:
Sipke Schoorstra
2015-07-02 15:34:08 +03:00
parent b580995e4b
commit 3c7fffc320

View File

@@ -11,6 +11,7 @@ using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Models;
using Orchard.Layouts.Services;
using Orchard.Layouts.Settings;
using Orchard.Layouts.ViewModels;
using Orchard.Logging;
@@ -89,6 +90,11 @@ namespace Orchard.Layouts.Drivers {
protected override DriverResult Editor(LayoutPart part, IUpdateModel updater, dynamic shapeHelper) {
return ContentShape("Parts_Layout_Edit", () => {
if (part.Id == 0) {
var settings = part.TypePartDefinition.Settings.GetModel<LayoutTypePartSettings>();
part.LayoutData = settings.DefaultLayoutData;
}
var viewModel = new LayoutPartViewModel {
LayoutEditor = _layoutEditorFactory.Create(part)
};