Well I know that, but I work on an extension for umbraco and I want to work with service layer not with the cache and this method which I wrote above does not return what I have expected - all icontent which have published version.
I must explicitly check if IContent is Published and if not than i have to take ByVersion. e.g.:
var data = ApplicationContext.Current.Services.ContentService.GetContentOfContentType(id).Where(f => !f.Trashed && f.HasPublishedVersion);
foreach (var iContent in data)
{
//if version is not published
if (!iContent.Published) {
//take published version and overwrite iContent
iContent = ApplicationContext.Current.Services.ContentService.GetByVersion(iContent.PublishedVersionGuid);
}
.... do the job
How to get just Published IContent with GetContentOfContentType
How to get published version from an IContent which has published version but also one version which is saved but not published?
Calling this method does not return Published version of an IContent
Hi Croban
Content Service returns IContent always. Use UmbracoHelper for getting IPublishedContent object, like that:
Thanks,
Oleksandr Skrypnyk
Well I know that, but I work on an extension for umbraco and I want to work with service layer not with the cache and this method which I wrote above does not return what I have expected - all icontent which have published version.
Just a guess, but could you use:
?
Hi Dan
This does not help also :(...
I must explicitly check if IContent is Published and if not than i have to take ByVersion. e.g.:
}
is working on a reply...