[Fixes #5820] Fixing default layout support

The default layout was just set in the text editor, and would not be
taken into account if the Part settings were not saved. A user would
then think the default template was there but actually not.

The change here is to leave the text editor empty, and if the setting is
empty load the default from the service. To actually have an empty template
a user needs to provide an empty object.
This commit is contained in:
Sebastien Ros
2015-09-25 15:07:56 -07:00
parent d9e833ba58
commit 8865041a8b
2 changed files with 10 additions and 7 deletions

View File

@@ -92,7 +92,15 @@ namespace Orchard.Layouts.Drivers {
return ContentShape("Parts_Layout_Edit", () => {
if (part.Id == 0) {
var settings = part.TypePartDefinition.Settings.GetModel<LayoutTypePartSettings>();
part.LayoutData = settings.DefaultLayoutData;
// If the default layout setting is left empty, use the one from the service
if (String.IsNullOrWhiteSpace(settings.DefaultLayoutData)) {
var defaultData = _serializer.Serialize(_layoutManager.CreateDefaultLayout());
part.LayoutData = defaultData;
}
else {
part.LayoutData = settings.DefaultLayoutData;
}
}
var viewModel = new LayoutPartViewModel {

View File

@@ -22,12 +22,7 @@ namespace Orchard.Layouts.Settings {
yield break;
var model = definition.Settings.GetModel<LayoutTypePartSettings>();
if (String.IsNullOrWhiteSpace(model.DefaultLayoutData)) {
var defaultData = _serializer.Serialize(_layoutManager.CreateDefaultLayout());
model.DefaultLayoutData = defaultData;
}
yield return DefinitionTemplate(model);
}