Excluding some result based on category

Posted by Community Admin on 03-Aug-2018 11:24

Excluding some result based on category

All Replies

Posted by Community Admin on 09-Jun-2011 00:00

Hello,
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 category....how can I do this?
Thanks

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);

Posted by Community Admin on 13-Jun-2011 00:00

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

This thread is closed