From 6b271f8f54389022ecdf579ee69b9d87db63eb0e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 20 Jul 2010 19:26:06 -0700 Subject: [PATCH] Create Display/Editor location settings for Parts and Fields --HG-- branch : dev --- .../Core/Common/Drivers/TextFieldDriver.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs index fb37f7b85..317e3dc8c 100644 --- a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs @@ -2,6 +2,7 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Core.Common.Fields; +using Orchard.Core.Common.Settings; namespace Orchard.Core.Common.Drivers { [UsedImplicitly] @@ -12,17 +13,27 @@ namespace Orchard.Core.Common.Drivers { public TextFieldDriver(IOrchardServices services) { Services = services; } - + private static string GetPrefix(TextField field, ContentPart part) { return part.PartDefinition.Name + "." + field.Name; } protected override DriverResult Display(ContentPart part, TextField field, string displayType) { - return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)); + var locationSettings = + field.PartFieldDefinition.Settings.GetModel("DisplayLocation") ?? + new LocationSettings { Zone = "primary", Position = "5" }; + + return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) + .Location(locationSettings.Zone, locationSettings.Position); } protected override DriverResult Editor(ContentPart part, TextField field) { - return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)).Location("primary", "5"); + var locationSettings = + field.PartFieldDefinition.Settings.GetModel("EditorLocation") ?? + new LocationSettings { Zone = "primary", Position = "5" }; + + return ContentFieldTemplate(field, TemplateName, GetPrefix(field, part)) + .Location(locationSettings.Zone, locationSettings.Position); } protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater) {