I am trying to create a simple setup in Orchard that appears on the settings page. I created a module that adds my ContentPart to the settings page and correctly creates a table in the database, but every time the cshtml file is rendered and access to the recording resource is saved, I continue to receive the next NHibernate record.
Not required: TekFlow.Contact.TekFlowEmailSettingsPartRecord. (TekFlow.Contact is the name of the module)
Below is all the code that I use to create the record / part / handler / driver needed in Orchard.
public class TekFlowEmailSettingsPartDriver : ContentPartDriver<TekFlowEmailSettingsPart> { public TekFlowEmailSettingsPartDriver() { T = NullLocalizer.Instance; } public Localizer T { get; set; } protected override DriverResult Editor(TekFlowEmailSettingsPart part, dynamic shapeHelper) { return ContentShape("Parts_TekFlowEmailSettings_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.TekFlowEmailSettings", Model: part, Prefix: Prefix) ); } protected override DriverResult Editor(TekFlowEmailSettingsPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper) { bool success = updater.TryUpdateModel(part, Prefix, null, null); return Editor(part, shapeHelper); } } [UsedImplicitly] public class TekFlowEmailSettingsPartHandler : ContentHandler { public TekFlowEmailSettingsPartHandler(IRepository<TekFlowEmailSettingsPartRecord> repository) { Filters.Add(new ActivatingFilter<TekFlowEmailSettingsPart>("Site")); Filters.Add(StorageFilter.For(repository)); } } public class TekFlowEmailSettingsPartRecord : ContentPartRecord { public virtual string SendToEmail { get; set; } } public class TekFlowEmailSettingsPart : ContentPart<TekFlowEmailSettingsPartRecord> { public string SendToEmail { get { return Record.SendToEmail; } set { Record.SendToEmail = value; } } } public class TekFlowEmailSettingsDataMigration : DataMigrationImpl { public int Create() { SchemaBuilder.CreateTable("TekFlowEmailSettingsPartRecord", table => table .ContentPartRecord() .Column<string>("SendToEmail", c => c.WithDefault(" SomeEmail@somedomain.com ").WithLength(255)) ); ContentDefinitionManager.AlterPartDefinition( typeof(TekFlowEmailSettingsPart).Name, cfg => cfg.Attachable()); return 1; } }
c # asp.net-mvc-2 orchardcms
runxc1 Bret Ferrier
source share