Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi we have a console app we've written which lets us migrate umbraco content as part of our migration strategy.
If we try and add a DocType to be a child of another DocType it won't inherit any of its parent's properties.
Code:
public int AddDocType(int? parentDocTypeId, string name, string docTypeAlias, IEnumerable<PropertyTypeGrouping> propertyGroupings, IEnumerable<string> childDocTypeAliases, string thumbnail = UmbracoThumbnails.Doc, string icon = UmbracoIcons.Doc, string[] templateAliases = null) { var contentTypeService = ServiceContext.ContentTypeService; var docTypeToAdd = parentDocTypeId.HasValue ? new ContentType(parentDocTypeId.Value) : new ContentType(-1); docTypeToAdd.Name = name; docTypeToAdd.Alias = docTypeAlias; docTypeToAdd.Thumbnail = thumbnail; docTypeToAdd.Icon = icon; if (templateAliases != null && templateAliases.Any()) { var templates = GetTemplates(templateAliases); docTypeToAdd.AllowedTemplates = templates; docTypeToAdd.SetDefaultTemplate(templates[0]); } contentTypeService.Save(docTypeToAdd); if(propertyGroupings != null && propertyGroupings.Any()) { AddTabsToDocType(docTypeToAdd, propertyGroupings.Select(p => p.Name)); AddPropertiesFromGroupings(docTypeToAdd, propertyGroupings); } if (childDocTypeAliases != null && childDocTypeAliases.Any()) { foreach (var childDocTypeAlias in childDocTypeAliases) { AllowNodeToCreateChildOfType(docTypeToAdd, childDocTypeAlias, false); } contentTypeService.Save(docTypeToAdd); } return docTypeToAdd.Id; }
Hi, What version of umbraco are you using? :)
Hi, What version of umbraco are you using? :) Are your doc types saving?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Content Service - Add DocType as Child Doesn't Inherit Properties
Hi we have a console app we've written which lets us migrate umbraco content as part of our migration strategy.
If we try and add a DocType to be a child of another DocType it won't inherit any of its parent's properties.
Code:
Hi, What version of umbraco are you using? :)
Hi, What version of umbraco are you using? :) Are your doc types saving?
is working on a reply...