In this video, you will learn how to create a View that shows content with the most site-wide favorites.

  • Go to "Structure => Views => Add new view" (admin/structure/views/add)
    • View Name: Most Favorited Content
    • Check "Create a page" (We’ll create a page and a block for this.)
      • Display: Unformatted list of fields (We’re actually going to display the teaser view. But choosing fields will let us also display the “Favorited count”.)
      • Items to display: 25
      • Create a menu link
      • Menu: Main menu
        • Link text: Most Favorited Content
    • Check "Create a block"
      • Display format: Unformatted list of fields
      • Items per page: 5
  • (Continue & edit)
  • Advanced
    • Click "Advanced"
    • Relationships: Click "Add"
      • Select
        • "Flags: Node flag"
        • “Flags: Node flag counter”
    • (Apply (all displays))
    • Configure Relationship: Flags
      • Flag: "Favorites"
      • By: Any user
    • (Apply (all displays))
    • Configure Relationship: Flags
      • Flag: “Favorites”
    • (Apply (all displays))
  • No results behavior
    • No results behavior: Click "Add"
    • Select "Global: Text area"
    • (Apply (all displays))
    • Label (Textarea): No one has favorited any content yet. :(
    • (Apply (all displays))
  • Click “Settings” next to “Query settings”
    • Select “Distinct” (This will eliminate duplicate results in our view. Without selecting “Distinct” a single piece of content will be listed for each time it has been flagged. ie: if an article is flagged by five people, it will be listed five times.)
    • (Apply (all displays))
  • Add fields
    • Flags: Flag counter
    • (Apply (all displays))
      • Uncheck “Create a label”
      • Prefix: “Favorited ” (Note the space at the end)
      • Prefix: “ times” (Note the space at the beginning)
      • (Apply (all displays))

Now, we’ll add additional fields just to the page view

  • Add fields
  • For: This page (override)
    • Content: Rendered Node
    • (Apply (all displays))
      • Uncheck “Create a label”
      • Display: Show complete entity
        • View mode: Teaser
      • (Apply (all displays))

Now, we just need to remove the title field from this display, since it’s already included in the Teaser mode.

  • Select: Content: Title
  • For: This page (override)
    • (Remove)
  • Select the “Block” display
  • Add a “More link” to the page view
    • Click “No” next to “More link”
    • Check the box next to “Create more link”
    • More link text: View all favorited content
  • (Save)

Next, we are going to display the block in the left sidebar

  • Go to "Structure => Blocks" (admin/structure/blocks)
    • Scroll down to "View: Most Favorited Content"
    • Click the dropdown for region and choose "Sidebar first"
  • (Save blocks)

Go to home, and the we see the “Most Favorited Content” block. Let’s favorite a few more articles to test out the “More link”.

Now, when we refresh, we see the “View all favorited content” link. When we click that, we are taken to the page view where we can see all of the content that has been favorited.

This has just been a small sampling of what you can do with the Flag module. I hope, though, that it has sparked ideas for you about how you can use it on your site.