ContentLifecycleStatus.Live returns unpublished items
Telerik Support,
I am following the documentation on this page for querying all news items using the native API and noticed that all items are returned. From what I understand in the documentation, only published items should be returned. I have a total of 53 news items, 51 published and 2 unpublished. I would expect to have 51 items returned by this method
private
List<NewsItem> GetAllNewsItemsNativeAPI()
NewsManager newsManager = NewsManager.GetManager();
return
newsManager.GetNewsItems().Where(newsItem => newsItem.Status == ContentLifecycleStatus.Live).ToList();
Hi Mark,
private
List<NewsItem> GetAllNewsItemsNativeAPI()
NewsManager newsManager = NewsManager.GetManager();
return
newsManager.GetNewsItems().Where(newsItem => newsItem.Status == ContentLifecycleStatus.Live && newsItem.Visible).ToList();
Hello Mark,
If you'll be using the Fluent API you can take advantage of the Publihed() filter (the spelling is correct, we have to fix a typo in this method, please accept our apologies), for example:
App.WorkWith().BlogPosts().Publihed().Get();
Published() will filter by a number of criteria to determine if the item is to be taken:
item.Visible ==
true
&&
item.Status == ContentLifecycleStatus.Live &&
item.PublicationDate <= DateTime.UtcNow &&
(item.ExpirationDate ==
null
|| item.ExpirationDate > DateTime.UtcNow);
FYI, if anyone runs across this and is trying to query custom modules then they can use this:
"Visible = true AND Status = Live AND PublicationDate <= DateTime.UtcNow AND (!ExpirationDate.HasValue OR ExpirationDate > DateTime.UtcNow)"
App.WorkWith().AnyContentItem(type).Manager.GetItems(type, query, order, skip, take);
FYI, if anyone runs across this and is trying to query custom modules then they can use this:
"Visible = true AND Status = Live AND PublicationDate <= DateTime.UtcNow AND (!ExpirationDate.HasValue OR ExpirationDate > DateTime.UtcNow)"
App.WorkWith().AnyContentItem(type).Manager.GetItems(type, query, order, skip, take);
Hi Erik,
Thank you for sharing this knowledge with the community, we truly appreciate ti.
Just wanted to add that the ExpirationDate will be set to a certain value when you have the item scheduled for unpublishing.
Greetings,
Boyan Barnev
the Telerik team
Hi Boyan,
Does the published() filter work with the news module?