mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
[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:
@@ -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 {
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user