public ActionResult EditNavigationItem(int id) { NavigationViewModel model = new NavigationViewModel(); var metadataTypes = _contentDefinitionService.GetUserDefinedTypes(); var contentItem = _contentManager.Get(id, VersionOptions.Latest); var pluralService = PluralizationService.CreateService(new CultureInfo("en-US")); model.EntityName = contentItem.As <MenuPart>().MenuText; model.EntityName = pluralService.Singularize(model.EntityName); var menuId = contentItem.As <MenuPart>().Record.MenuId; var perspectiveItem = _contentManager.Get(menuId, VersionOptions.Latest); model.Title = perspectiveItem.As <TitlePart>().Title; model.IconClass = contentItem.As <ModuleMenuItemPart>().IconClass; model.Entities = metadataTypes.Select(item => new SelectListItem { Text = item.Name, Value = item.Name, Selected = item.Name == model.EntityName }).ToList(); model.NavigationId = id; model.PrespectiveId = menuId; return(View(model)); }
public override IEnumerable <TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) { if (definition.FieldDefinition.Name == "ReferenceField" || definition.FieldDefinition.Name == "ReferenceFieldCreate") { var metadataTypes = _contentDefinitionService.GetUserDefinedTypes(); var model = definition.Settings.GetModel <ReferenceFieldSettings>(); model.ContentTypeList = metadataTypes.Select(item => new SelectListItem { Text = item.Name, Value = item.Name, Selected = item.Name == model.ContentTypeName }).ToList(); yield return(DefinitionTemplate(model)); } }