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 I wanted to know in code how can I allow a doc type to add a value to the structure ending up in the cmsContentTypeAllowedContentType table.
I've tried extending the Content Types AllowedContentTypes array but am not sure if that's the right way to do it:
var newContentTypeSize = parentType.AllowedContentTypes.Count() + 1; Array.Resize(ref allowedChildContentTypes, newContentTypeSize); var currentSort = allowedChildContentTypes.Max(c => c.SortOrder); allowedChildContentTypes[newContentTypeSize - 1] = ???
The way i have done it in the past (works on v6 api - no changes as far as i can see for v7) is to get a List
List<ContentTypeSort> allowedTypes = new List<ContentTypeSort>(item.AllowedContentTypes);
assuming you have the docType you want to add - i add it to the list and assign the list back to the original ContentType
allowedTypes.Add( new ContentTypeSort(new Lazy<int>(() => allowedDoc.Id), sortOrder, allowedDoc.Name)); item.AllowedContentTypes = allowedTypes;
then you should beable to save the doctype back with the new types
Thanks Kevin,
the list makes it much cleaner than the array!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
API v7 Allow a node to create child of type.. i.e. add to structure list
Hi I wanted to know in code how can I allow a doc type to add a value to the structure ending up in the cmsContentTypeAllowedContentType table.
I've tried extending the Content Types AllowedContentTypes array but am not sure if that's the right way to do it:
The way i have done it in the past (works on v6 api - no changes as far as i can see for v7) is to get a List
assuming you have the docType you want to add - i add it to the list and assign the list back to the original ContentType
then you should beable to save the doctype back with the new types
Thanks Kevin,
the list makes it much cleaner than the array!
is working on a reply...