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

Forums / General Discussions / Hide/Show Contents (Like news)

Hide/Show Contents (Like news)

6 posts, 0 answered
  1. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    15 Jul 2011
    Link to this post
    Hi!

    What If I want to hide/show some contents, like I have news list but I want to show only some of them? I used Fluent API and tried to achieve this functionality by unpublished news item but got nothing.

    Would anyone like to tell me?


    Thanks in advance!
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    15 Jul 2011
    Link to this post
    Hi Waqar,

    Actually, unpublished items will not show in the News widget, can you please elaborate on the API implementation that you have used to unpublish the items? I'd kindly ask you to try unpublishing an item from Sitefinity backend and check if it will appear on the frontend page where you have News widget.

    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
  3. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    16 Jul 2011
    Link to this post
    Thanks for the reply!

    Actually I am not using sitefinity news widget, I am using Fluent API in custom control for retrieving news items. Can you give me the code that only shows published items?
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    18 Jul 2011
    Link to this post
    Hi Waqar,

    You can filter by ContentLifeCycleStatus.Live. Please take a look at the below code sample:
    var newsSelection = App.WorkWith()
                                                .NewsItems()
                                                .Where(nI => nI.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
                                                .Get()
                                                .ToList();



    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
  5. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    18 Jul 2011
    Link to this post
    I wrote this code but it showing all news items published and unublished.

    Any idea?
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    18 Jul 2011
    Link to this post
    Hi Waqar,

    I'm sorry for misleading you, it looks like I've missed to add a filter for the ones that have Visible set to false. Please try using the below code sample, it should return only published items.
    var newsSelection = App.WorkWith()
                        .NewsItems()
                      .Where(nI => nI.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && nI.Visible == true)
                       .Get()
                      .ToList();



    All the best,
    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
6 posts, 0 answered