diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs index 07fded3a2..2667690bd 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Services/ContentDefinitionService.cs @@ -12,16 +12,20 @@ using Orchard.Localization; namespace Orchard.ContentTypes.Services { public class ContentDefinitionService : IContentDefinitionService { private readonly IContentDefinitionManager _contentDefinitionManager; + private readonly IEnumerable _contentPartDrivers; private readonly IEnumerable _contentFieldDrivers; private readonly IContentDefinitionEditorEvents _contentDefinitionEditorEvents; public ContentDefinitionService( IOrchardServices services, IContentDefinitionManager contentDefinitionManager, + IEnumerable contentPartDrivers, IEnumerable contentFieldDrivers, - IContentDefinitionEditorEvents contentDefinitionEditorEvents) { + IContentDefinitionEditorEvents contentDefinitionEditorEvents) + { Services = services; _contentDefinitionManager = contentDefinitionManager; + _contentPartDrivers = contentPartDrivers; _contentFieldDrivers = contentFieldDrivers; _contentDefinitionEditorEvents = contentDefinitionEditorEvents; T = NullLocalizer.Instance; @@ -141,7 +145,12 @@ namespace Orchard.ContentTypes.Services { public IEnumerable GetParts() { var typeNames = GetTypes().Select(ctd => ctd.Name); - return _contentDefinitionManager.ListPartDefinitions().Where(cpd => !typeNames.Contains(cpd.Name)).Select(cpd => new EditPartViewModel(cpd)); + // code-defined parts + var codeDefinedParts = _contentPartDrivers.SelectMany(d => d.GetPartInfo().Select(cpi => new EditPartViewModel {Name = cpi.PartName})); + // user-defined parts + var contentParts = _contentDefinitionManager.ListPartDefinitions().Where(cpd => !codeDefinedParts.Any(m => m.Name == cpd.Name)).Select(cpd => new EditPartViewModel(cpd)); + // all together now, except for those parts with the same name as a type (implicit type's part or a mistake) + return contentParts.Where(m => !typeNames.Contains(m.Name)).Union(codeDefinedParts).OrderBy(m => m.Name); } public EditPartViewModel GetPart(string name) { diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddPartsTo.ascx b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddPartsTo.ascx index 7f70491e7..b9055c5fd 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddPartsTo.ascx +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/Admin/AddPartsTo.ascx @@ -13,7 +13,7 @@ using (Html.BeginFormAntiForgeryPost()) { %> string.Format( "{0} {3}", Html.CheckBox(fieldNameStart + "IsSelected"), - fieldNameStart + "IsSelected", + ViewData.TemplateInfo.GetFullHtmlFieldId(fieldNameStart + "IsSelected"), partSelection.PartName, Html.Hidden(fieldNameStart + "PartName", partSelection.PartName))); },