Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Guys,
I couldn't find many helpful posts on this so I thought I would open a question.
How do you....
Copy a node and all its children programmatically
Then publish this node and all its children programmatically
Thanks in advanced
Kind Regards
David
Hi David,
Did you take take a look at the docs? https://our.umbraco.org/documentation/Reference/Management/Services/ContentService
Thanks.
I got the copy down. Its was the .PublishWithChildren method I was looking for.
Thanks for pointing me in the right direction.
I will give this a try and re-post the full code.
So here is the filly copy to copy and publish including children.
var contentService = ApplicationContext.Current.Services.ContentService; var documentToCopy = contentService.GetById(1592); var newDoc = contentService.Copy(documentToCopy, 1558, false, 0); contentService.PublishWithChildrenWithStatus(newDoc, 0, true);
If you want to copy children it's important that you set the following.
(newDoc, 0, true); - include unpublished
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Copying & Publishing Nodes Programmatically
Hi Guys,
I couldn't find many helpful posts on this so I thought I would open a question.
How do you....
Copy a node and all its children programmatically
Then publish this node and all its children programmatically
Thanks in advanced
Kind Regards
David
Hi David,
Did you take take a look at the docs? https://our.umbraco.org/documentation/Reference/Management/Services/ContentService
Thanks.
I got the copy down. Its was the .PublishWithChildren method I was looking for.
Thanks for pointing me in the right direction.
I will give this a try and re-post the full code.
Hi Guys,
So here is the filly copy to copy and publish including children.
If you want to copy children it's important that you set the following.
(newDoc, 0, true); - include unpublished
is working on a reply...