Copied to clipboard

Flag this post as spam?

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


  • BJ Patel 75 posts 180 karma points
    Jul 13, 2021 @ 03:59
    BJ Patel
    0

    How to Create node on Root In umbraco 8 From controller

    Hi,

    I use the following code to create a node from the Controller: which create a node on the base of the Parent node [ParentGuid]:

    using Umbraco.Web.Mvc;
    var contentService = Services.ContentService; 
    var newNode = contentService.Create("node Name", [ParentGuid], "docTypeName");
        ....
         ....                 
    
        contentService.Save(newNode); 
    

    Now I need to create a node on the root level, so need guidance on it. How to create a node at the root level?

    Thanks

    BJ

  • Marc Goodson 1577 posts 10543 karma points MVP 6x c-trib
    Jul 13, 2021 @ 06:15
    Marc Goodson
    0

    Hi BJ

    Historically, if you set the value of the parent to -1

    That means the 'root' of the tree you are creating the item in.

    I say historically, as I haven't done it for a while, and I'm not sure things changed when udi's were introduced, but I reckon it's 'still the way'.

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft