Copied to clipboard

Flag this post as spam?

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


  • Ahmed 16 posts 96 karma points
    Jul 16, 2013 @ 10:46
    Ahmed
    1

    programmatically creating a document type

    can i create a new document type programmatically  ??

  • Jeffrey Schoemaker 408 posts 2138 karma points MVP 8x c-trib
    Jul 23, 2013 @ 20:43
    Jeffrey Schoemaker
    101

    Hi Ahmed,

    you can! The code will be something like this, depending on the Umbraco version you're working with:

    // Umbraco 4
    DocumentType dt = DocumentType.MakeNew(new umbraco.BusinessLogic.User(0), "My New DocumentType");
    dt.Save();

    // Umbraco 6
    var cs = ApplicationContext.Current.Services.ContentTypeService;
    ContentType ct = new ContentType(-1);
    ct.Name = "My New v6 DocType"; ct.Alias = "myNewV6Doctype";
    cs.Save(ct);

     About the Umbraco 6-code I'm not 100 percent sure, but it's something like that.

    Cheers, Jeffrey

  • Ahmed 16 posts 96 karma points
    Jul 31, 2013 @ 13:08
    Ahmed
    0

    thanks Jeffery 

    i am using v 6.0 and the code you wrote helped very much

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies