Copied to clipboard

Flag this post as spam?

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


  • jivan thapa 194 posts 681 karma points
    Mar 29, 2011 @ 10:48
    jivan thapa
    0

    how to relate/assign template to document using api

    I create document type and template, don't know how to assign "TestTemplate" to "Test" document type.

                DocumentType dt = DocumentType.MakeNew(user, "Test");
                Template t = Template.MakeNew("TestTemplate", user);
                     dt.Save();

    thanks.

  • Pasang Tamang 258 posts 458 karma points
    Mar 29, 2011 @ 11:11
    Pasang Tamang
    0

    Hi jeevan,

    You may assign value to dt.DefaultTemplate or dt.allowedTemplates.

    Hope this helps

    Pnima

  • jivan thapa 194 posts 681 karma points
    Mar 29, 2011 @ 15:07
    jivan thapa
    0

    hi, pasang, thanks for reply.

    DefaultTemplate can have only one. if you want to assign more than one template using api how do you assign?

    dt.allowedTemplates requires collection of Templates. i.e Templates[]

    how do you pass that collection of Templates. 

     

  • jivan thapa 194 posts 681 karma points
    Mar 29, 2011 @ 15:11
    jivan thapa
    0

    hi, pasang, thanks for reply.

    DefaultTemplate can have only one. if you want to assign more than one template using api how do you assign?

    dt.allowedTemplates requires collection of Templates. i.e Templates[]

    how do you pass that collection of Templates. 

     

  • Dennis Spijkerboer 53 posts 95 karma points
    Apr 05, 2011 @ 16:25
    Dennis Spijkerboer
    0

    You should be able to do it like this:

    umbraco.cms.businesslogic.template.Template[] templates = new umbraco.cms.businesslogic.template.Template[2];
    templates[0] = new umbraco.cms.businesslogic.template.Template(234);
    templates[1] = new umbraco.cms.businesslogic.template.Template(456);                       
    dt.allowedTemplates = templates;
  • 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