Get All Published & Unpublished Content in the custom property API Call in Umbraco 8.1.4
Hello All,
I have created one custom property for radio button selection which I got all published content in the list but as per my requirement, I need to get all published and Unpublished contents of the parent in the list in the back office.
In Umbraco 7 I got all children using the below code.
var contentService = ApplicationContext.Services.ContentService;
var contentTypeService = ApplicationContext.Services.ContentTypeService;
var list = contentService.GetChildren(Id).Where(con => con.Name.Contains(Key) || Key == "")
.Select(x => new MyContent { ID = Convert.ToInt32(x.Id), Name = x.Name });
Now, I do the same process in the Umbraco 8 then I can`t get the list because ApplicationContext Service support removes in the Umbraco 8.
So, anyone has any idea about how to get all parent nodes children of published and unpublished in the list using Umbraco 8.1.4 version?
The services still exist and work in pretty much the same way, but the way you access them has changed. Since you're writing a custom property editor, you can create a constructor for your class with parameters for the services you need, and Umbraco will provide them. Something like:
public class MyPropertyEditor : IDataEditor
{
private readonly IContentService _contentService;
public MyPropertyEditor(IContentService contentService)
{
_contentService = contentService;
}
...
}
Get All Published & Unpublished Content in the custom property API Call in Umbraco 8.1.4
Hello All,
I have created one custom property for radio button selection which I got all published content in the list but as per my requirement, I need to get all published and Unpublished contents of the parent in the list in the back office.
In Umbraco 7 I got all children using the below code.
Now, I do the same process in the Umbraco 8 then I can`t get the list because ApplicationContext Service support removes in the Umbraco 8.
So, anyone has any idea about how to get all parent nodes children of published and unpublished in the list using Umbraco 8.1.4 version?
Thanks in advance.
The services still exist and work in pretty much the same way, but the way you access them has changed. Since you're writing a custom property editor, you can create a constructor for your class with parameters for the services you need, and Umbraco will provide them. Something like:
Hello Steve,
Using the Above solution I get only published content data with a single node, not any method found which gets all children content also.
I need to get the Unpublished node in the custom property for the back office.
If you have any other solution then tell me so I can try and check it.
Thanks in Advance.
Something like this should work:
Hi Steve Megson,
Thanks for giving me a useful code.
Now I get all Unpublished content in the custom property.
is working on a reply...