In my project, i need to create chidnodes dynamically,
public class PresentationController : UmbracoApiController
{
public string GetPresentation(int umbracoNodeId)
{
var franchise = Umbraco.TypedContent(umbracoNodeId);
if (franchise != null)
{
var comments = franchise.Children.Where(x => x.DocumentTypeAlias == "Presentation");
if (comments.Any())
{
foreach (var comment in comments)
{
var region = comment.GetProperty("title").Value.ToString();
}
}
}
return "success";
}
Using above code i can get parent node and available children. How can i create a new child?
// Get the Umbraco Content Service
var contentService = Services.ContentService;
var product = contentService.CreateContent(
"my new presentation", // the name of the product
1055, // the parent id should be the id of the group node
"Presentation", // the alias of the product Document Type
0);
// We need to update properties (product id, original name and the price)
product.SetValue("title", "My new presentation");
// finally we need to save and publish it (which also saves the product!) - that's done via the Content Service
contentService.SaveAndPublish(product);
Create Child node using C#
Hi all,
In my project, i need to create chidnodes dynamically,
Using above code i can get parent node and available children. How can i create a new child?
Umbraco version 6.1.6
Please help, Thanks
Hi Erma
hope this post help you: (link here)
Cheers
Ali
Hi, This will help you :)
http://umbraco.com/follow-us/blog-archive/2013/1/22/introducing-contentservice-aka-the-v6-api.aspx
Charlie.
Hi again,
Thanks all for responses.
@Charlie, Very good article. It helped.
I got it working using following code,
Hope this might help someone
is working on a reply...