Find news widget control by category settings?
We have multiple news pages, each set up to display only items from a single category. I'm trying to build URLs to link to the correct page, which I have managed to do for a custom blog widget. However, unlike the BlogPosts, the NewsItems do not have a Parent, and I can't figure out how to get to the right page without adding a custom field to the news items.
Is it possible to extend the code below to find out which of the NewsView controls i a list of pages has been set to display only news from certain categories?
var NewsPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(p => p.Page != null &&
p.Page.Controls.Where(c => c.ObjectType.StartsWith(typeof(NewsView).FullName)).Count() > 0)
.Get().ToList();
foreach (var tnp in targetNewsPages)
var newsViews = (from a in tnp.Page.Controls.Where(p => p.ObjectType.StartsWith(typeof(NewsView).FullName)) select a).FirstOrDefault();
Hello Ryan,
When you filter a control through UI to show data from a certain category we update a property called AdditionalFilter of the frontend definition
Home > ControlDefinition > Views > NewsFrontendList
The property contains a string similar to this one where we add the taxon name - in my case is "test"
FieldName":"Category","FieldType":"System.Guid","Operator":"Contains","__msdisposeindex":723,"Name":
"test","_itemPathSeparator":"_","__msdisposeindex":724
You can get is as shown below
var man = PageManager.GetManager();
var NewsPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(p => p.Page != null &&
p.Page.Controls.Where(c => c.ObjectType.StartsWith(typeof(NewsView).FullName)).Count() > 0)
.Get().ToList();
foreach (var tnp in NewsPages)
var newsViews = (from a in tnp.Page.Controls.Where(p => p.ObjectType.StartsWith(typeof(NewsView).FullName)) select a).FirstOrDefault();
var c = man.LoadControl(newsViews) as NewsView;
var categoryName = ((Telerik.Sitefinity.Web.UI.ContentUI.ContentViewMasterDefinition)(((Telerik.Sitefinity.Web.UI.ContentUI.ContentView)(c)).masterViewDefinition)).AdditionalFilter.QueryItems[1].Name
Best wishes,
Ivan Dimitrov
the Telerik team
Awesome, thanks Ivan.