Hide/Show Contents (Like news)
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!
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
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?
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();
I wrote this code but it showing all news items published and unublished.
Any idea?
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();