Once content has been rated, you can use Views to sort and filter content listings based on those ratings. So, in this video, I'll show you how to do that.

Note: I'll create 5 articles using Devel Generate before I create the view

Let's start out by creating a list of recent articles.

Creating a "Recent Articles" View

  • Go to "Structure => Views => Add new view" (admin/structure/views/add)
  • View name: Recent Articles
  • Show: Content of type Article
  • Create a page (We'll just create a page for this example, but you could also create a block to display in the sidebar.)
  • Display format: Unformatted list of fields
  • (Continue & edit)

Ok, so right now, if we scroll down to the preview, we see all of our articles listed. Let's say we want to limit this to only show content with a review of 4 stars or better. We can do that by adding a relationship and a filter.

Filtering by Content Rating

  • Advanced
    • Click "Add" next to "Relationships"
    • Choose "Content: Vote results"
    • (Apply (all displays))
    • Identifier: Fivestar Review (This will differentiate this relationship from others that we will add.)
    • [ ] Require this relationship (I won't require this because we have to add a relationship for each rating widget, if we want to use more than one (which we will in just a minute).)
    • Value type: Percent (We're going to show content with a rating of at least 75%.)
    • Vote tag: Review (This will let us filter and sort based on the fivestar widget we added earlier. If multiple rate widgets utilize the same tag their results will be combined. This is why we used a different tag for each widget we created.)
    • Aggregation function: Average vote (We want to access the average vote.)
  • (Apply (all displays))

Ok, we're still showing all results, so let's add the filter to only show content with an average rating of at least 75%.

  • Click "Add" next to "Filter Criteria"
  • Choose "Vote results: Value"
  • (Apply (all displays))
  • Relationship: Fivestar Review
  • Operator: Is greater than or equal to
  • Value: 75
  • (Apply (all displays))

Now, when we scroll down, our preview only shows content that has been rated with an average of at least 75%! One problem with this is that it won't ever show brand new content, so let's add an OR filter to also show content that hasn't yet been rated.

  • Click "Add" next to "Filter Criteria"
  • Choose "Vote results: Value"
  • (Apply (all displays))
  • Relationship: Fivestar Review
  • Operator: Is empty (NULL)
  • (Apply (all displays))

Now, we need to use a somewhat advanced Views feature to utilize "And/Or" filter groups.

  • Click the dropdown for "Filter Criteria"
  • Click "And/Or, Rearrange"
  • Click "Create new filter group"
  • In the new group change the Operator to "Or"
  • Drag both "Fivestar Review" filters to the new group

Now, the view will filter to content that is both published, and of the article content type, AND either not voted or has a rating of at least 75%.

  • (Apply (all displays))

Okay, now more articles are in the list. I'm going to view the first one, and give it a 1 star review. Now, if we update the preview that article is no longer in the list.

In the next video, we'll take a look at how we can use rating results to sort our View to show higher rated content first.