Creating Nodes and items programatically with data from website entered by user
Hi,
I need a new node and subnode to be created programatically in Umbraco
Scenario: Website user(not umbraco user) will input some details through a webpage in our site. I need to create a node/childnodes and new items under these nodes using the data from the webpage.
I just typed you up a very simply insert. I am sure you can adapt this for your needs!.
public static int InsertExample(int parentNodeId)
{
var contentService = ApplicationContext.Current.Services.ContentService;
var name = "Enter name of the node here"
var data = contentService.CreateContent(name, parentNodeId, "Enter document type alias here", 0);
//set the properties of the doument type here. Use the property alias
//for example purposes I just assumed my document type has firstname, lastname, phone
data.SetValue("firstName", "Peter");
data.SetValue("lastName", "Pan");
data.SetValue("phone", "0123456789");
// save and publish
contentService.SaveAndPublishWithStatus(data);
return data.Id;
}
Creating Nodes and items programatically with data from website entered by user
Hi, I need a new node and subnode to be created programatically in Umbraco
Scenario: Website user(not umbraco user) will input some details through a webpage in our site. I need to create a node/childnodes and new items under these nodes using the data from the webpage.
How can I do This?
Thanks in advance
Look this:
https://umbraco.com/follow-us/blog-archive/2013/1/22/introducing-contentservice-aka-the-v6-api/
https://our.umbraco.org/documentation/reference/management/services/contentservice
Hi,
I just typed you up a very simply insert. I am sure you can adapt this for your needs!.
hope this helps.
Kind Regards
David
is working on a reply...