+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / ContentLifecycleStatus.Live returns unpublished items

ContentLifecycleStatus.Live returns unpublished items

8 posts, 0 answered
  1. Mark
    Mark avatar
    22 posts
    Registered:
    16 Sep 2012
    14 Feb 2012
    Link to this post
    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
  2. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    14 Feb 2012
    Link to this post
    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
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    05 Dec 2016
    14 Feb 2012
    Link to this post
    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
  4. Erik
    Erik avatar
    62 posts
    Registered:
    02 May 2011
    21 Jun 2012
    Link to this post
    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.

  5. Erik
    Erik avatar
    62 posts
    Registered:
    02 May 2011
    21 Jun 2012
    Link to this post
    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.

  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    05 Dec 2016
    21 Jun 2012
    Link to this post
    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
  7. Erik
    Erik avatar
    62 posts
    Registered:
    02 May 2011
    10 Jul 2012
    Link to this post
    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.
  8. Ivy
    Ivy avatar
    1 posts
    Registered:
    06 Sep 2012
    13 Sep 2012
    Link to this post
    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.
8 posts, 0 answered