ContentLifecycleStatus.Live returns unpublished items

Posted by Community Admin on 04-Aug-2018 00:58

ContentLifecycleStatus.Live returns unpublished items

All Replies

Posted by Community Admin on 14-Feb-2012 00:00

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();

We are using SF 4.2.1650.  Is this a known issue? 

Mark

Posted by Community Admin on 14-Feb-2012 00:00

Hi Mark,

They have something missing from their documentation it appears, what you should have is :

private List<NewsItem> GetAllNewsItemsNativeAPI()
    NewsManager newsManager = NewsManager.GetManager();
   
    return newsManager.GetNewsItems().Where(newsItem => newsItem.Status == ContentLifecycleStatus.Live && newsItem.Visible).ToList();

That should fix it for you.

Cheers
Sean

Posted by Community Admin on 14-Feb-2012 00:00

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);


Kind regards,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Jun-2012 00:00

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)"

Except that I think there is a bug so the ExpirationDate isn't respected. It also always comes back null. But you can query like this:

App.WorkWith().AnyContentItem(type).Manager.GetItems(type, query, order, skip, take);

Where query is the string above.

Posted by Community Admin on 21-Jun-2012 00:00

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)"

Except that I think there is a bug so the ExpirationDate isn't respected. It also always comes back null. But you can query like this:

App.WorkWith().AnyContentItem(type).Manager.GetItems(type, query, order, skip, take);

Where query is the string above.

Posted by Community Admin on 21-Jun-2012 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 10-Jul-2012 00:00

Hi Boyan,

That was not my experience. I had set the date for when a node should be unpublished and the date still came back null.

Posted by Community Admin on 13-Sep-2012 00:00

Does the published() filter work with the news module?

Also, I added the && NewsItem.Visible criteria, but the results returned still shows all news... published as well as unpublished.

This thread is closed