Copied to clipboard

Flag this post as spam?

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


  • glob 72 posts 172 karma points
    Jul 31, 2013 @ 14:08
    glob
    0

    Programmatically setting a template on node creation

    Hello,

    I try to create umbraco node Programmatically like this


    var author = new User("user name");
    var product = contentService.CreateContent(sender.Text, parentNodeId,"uBlogsyPost", userId.Id);
    product.SetValue("uBlogsyContentTitle", sender.Text);
    product.SetValue("uBlogsyContentBody", post);

    now i want to set template like "TextTemplate" , is it possible? how..?

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Jul 31, 2013 @ 15:12
    Kevin Jump
    0
    product.Template = "TextTemplate" ; 
    

    should set it.

    you will need to save the content afterwards

    i.e contentService.Save(product, 0, true); (user0 - should replace if you have one)

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Jul 31, 2013 @ 15:13
    Kevin Jump
    102

    sorry complety ignore me

    it's

    ITemplate template = ApplicationContext.Current.Services.FileService.GetTemplate("TextTemplate");
    
    if (template != null)
       product.Template = template;
    
  • glob 72 posts 172 karma points
    Jul 31, 2013 @ 15:56
    glob
    0

    thanks for your quick reply...solved

Please Sign in or register to post replies

Write your reply to:

Draft