I'm trying to create my main Document Types programmatically on ApplicationStarted.
Is it possible to set Composition of a ContentType programmatically?
you need to lookup the other ContentType and add it to a collection of IContentTypeCompositions and then assign this to the ContentTypeComposition value of the parent content type.
So for example (assuming you have a contentTypeService refrence)
List<IContentTypeComposition> compositions = new List<IContentTypeComposition>();
var myComp = contentTypeService.GetContentType(compAlias);
compositions.Add(myComp);
myContentType.ContentTypeComposition = compositions;
contentTypeService.Save(myContentType);
Set ContentType Composition
Hi,
I'm trying to create my main Document Types programmatically on ApplicationStarted. Is it possible to set Composition of a ContentType programmatically?
-Thanks
Hi
you need to lookup the other ContentType and add it to a collection of IContentTypeCompositions and then assign this to the ContentTypeComposition value of the parent content type.
So for example (assuming you have a contentTypeService refrence)
you can see this (and a bit more) in the uSync source - as it does this on import of content types from disk.
is working on a reply...