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

Forums / General Discussions / User Control: How to grab news items in specific category?

User Control: How to grab news items in specific category?

4 posts, 0 answered
  1. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    17 Sep 2009
    Link to this post
    I created a user control to display the latest two news which created in Modules > News. I categorized all news items in several categories. How can I grab the latest two in specific category? My user control currently gets the latest two items in all news items. Thanks.
  2. Nikolai
    Nikolai avatar
    216 posts
    Registered:
    21 Nov 2016
    17 Sep 2009
    Link to this post
    Hi Developer,

    Here is a sample you can observe on how you can filter the News items by category:

     
            var man = new ContentManager("News"); 
            string categoryName = "Sport"
            List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); 
            // add a new filter to the list 
            filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Category", categoryName, Telerik.Cms.Engine.SearchCondition.Equal)); 
            IList items = man.GetContent(0, 2, filter.ToArray()); 

    Regards,
    Nikolai
    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.
  3. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    17 Sep 2009
    Link to this post
    It works perfectly. Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Sep 2009
    Link to this post
    Hello,

    Always glad to help.

    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.
Register for webinar
4 posts, 0 answered