Determine the content statuses in Umbraco
# help-with-umbraco
t
How correctly classify the content items, including handling the distinction between published, draft, trashed, and unpublished states?
m
In what context are you wanting to work out the state?
t
I didn't understand your phrase, I use Umbraco and thanks for all who was part to build this excellent CMS! *Back to subject*: I use the
contentService
as below but trashed property I find it always false even if the item in Recycle Bin!
Copy code
// Retrieve all content items
            var allContent = _contentService.GetRootContent().SelectMany(GetDescendantsRecursive).ToList();
var trashedCount = allContent.Count(c => c.Trashed);
m
I was referring to in a request, the UI etc? I had no context on how you can tell without some code
t
No problem, I think the idea clear now after the code above.
m
_contentService.GetRootContent() I think is why you arent seeing any Trashed items as that query will be removing the mas the "Root" id for the recycle bin is different if i remeber correctly
GetPagedContentInRecycleBin would let you get all he trashed items
Copy code
IContent c;

//Has draft and cultures
c.Edited;
c.IsCultureEdited("en");

//is published and in what cultures
c.Published;
c.PublishedCultures;


//In the recycle bin
c.Trashed //but your query is removing these
t
Excellent, I confirm it is working now. Thank you, @Matt Wise
3 Views