More in this section

Forums / General Discussions / Excluding some result based on category

Excluding some result based on category

2 posts, 0 answered
  1. Paolo
    Paolo avatar
    147 posts
    11 Jun 2009
    09 Jun 2011
    Link to this post
    I need to show the most viewed items based on some criteria I paste here....... I also wish to show only the items that don't belong to a specific can I do this?

    int value = Math.Abs(giorniPrecedenti);
                  DateTime DataMinima = DateTime.Now.AddDays(-value);
                  var res1 = App.WorkWith().Documents().Where(o1 => o1.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && o1.ViewsCount > 0
                           && o1.PublicationDate >= DataMinima && o1.PublicationDate <= DateTime.Now ).OrderByDescending(o2 => o2.ViewsCount);
                  res1 = res1.Take(numItems);
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    13 Jun 2011
    Link to this post
    Hello Paolo,

    1. Is there a problem with the query you posted above. I see that you use ViewCount property of the content item which shows how many items an items is view and data time comparison.

    2. To get items that does not belong to a given category you can search through item's properties for the category, if it is not found, add it to a  list

    var ni = App.WorkWith().NewsItems().Where(cnt => cnt.Status ==          Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get();
    foreach (NewsItem itm in ni)
        var cat = TypeDescriptor.GetProperties(itm).Find("SomeCategory", false);
        if (cat != null)
            // add this item to a list

    All the best,
    Ivan Dimitrov
    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
2 posts, 0 answered