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
In a surface controller, I need to get ALL the children of a particular page. The code I've got is:
IPublishedContent blogParentPage = Umbraco.TypedContent(blogParentPageId); IEnumerable<IPublishedContent> existingPosts = blogParentPage.Children;
... but this is only returning the published children. I need the unpublished children too.
Any hints or suggestions?
-- Norman Lynch
you have to go via the ContentService if you want unpublished nodes as well.
Disclaimer: this is certainly NOT how you should fetch data in a view, so you better have a good reason to do that!!
See https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService
On another note. How do you use ContentSerice in a View? I can't get it to work...
(I also want unpublished content) hehe :)
That worked perfectly!
IEnumerable<IContent> existingPosts = Services.ContentService.GetChildren(blogParentPageId);
this should work in a view
UmbracoContext.Current.Application.Services.ContentService
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do I get published AND unpublished children of a page
In a surface controller, I need to get ALL the children of a particular page. The code I've got is:
... but this is only returning the published children. I need the unpublished children too.
Any hints or suggestions?
-- Norman Lynch
you have to go via the ContentService if you want unpublished nodes as well.
Disclaimer: this is certainly NOT how you should fetch data in a view, so you better have a good reason to do that!!
See https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService
On another note. How do you use ContentSerice in a View? I can't get it to work...
(I also want unpublished content) hehe :)
That worked perfectly!
this should work in a view
UmbracoContext.Current.Application.Services.ContentService
is working on a reply...