More in this section

Forums / Developing with Sitefinity / How do i find the selected news categorys from the newsview control

How do i find the selected news categorys from the newsview control

2 posts, 0 answered
  1. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    07 Jan 2010
    Link to this post
    Hi
    I'm working on a custom control inheriting off the newsview control, However how do i find the selected news categorys? as i dont seem to be able to see how?

    Thanks
    Anthony
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jan 2010
    Link to this post
    Hi Anthony Smith,

    You can override SetItemMetaData method where you have access to the content items. Then call GetMetaData method with "Category" parameter. This will return a list of the selected categories or you can create a generic ICategory list and populate it.

    The following code will also return the categories that has been selected and set through NewsViewControlDesigner as a FilterExpression.

    protected override void CreateContentList()
     
    {
     
    base.CreateContentList();
    string filterExpression = this.FilterExpression;
    Telerik.Cms.Engine.ContentViewFiltering.ContentFilterBuilder filterBuilder = new Telerik.Cms.Engine.ContentViewFiltering.ContentFilterBuilder(this);
    string[] categories = filterBuilder.ParseCategories();
     
    }

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered