Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Zihadul Azam 26 posts 171 karma points c-trib
    Feb 01, 2018 @ 14:29
    Zihadul Azam

    Set ContentType Composition


    I'm trying to create my main Document Types programmatically on ApplicationStarted. Is it possible to set Composition of a ContentType programmatically?


  • Kevin Jump 2129 posts 13459 karma points MVP 6x c-trib
    Feb 01, 2018 @ 14:37
    Kevin Jump


    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);
    myContentType.ContentTypeComposition = compositions;

    you can see this (and a bit more) in the uSync source - as it does this on import of content types from disk.

Please Sign in or register to post replies

Write your reply to: