A common use case for grouping by fields, like we did in the last video, is to group posts by date. So, in this video, I will show you how to use a custom date field to group all content by year and create a yearly archive.

  • Go to "Structure => Views => Add new view" (admin/structure/views/add)
  • View name: Yearly Archive
  • Display format: Unformatted list
    • of: fields
  • (Continue & edit)

Fields

  • Click "Add" next to fields
  • [x] Content: Post date
  • (Apply(all displays))
  • [ ] Create a label
  • [x] Exclude from display (The only reason we're adding this field is so that we can group all of the site content by the year it was posted. We don't actually want to display the post date next to each piece of content.)
  • Date format: Custom
    • Custom date format: Y (A 4 digits numeric representation of a year. ie: 1999 or 2003)
  • (Apply(all displays))

Format

  • Format
    • Click "Settings"
    • Grouping field Nr.1: Post date
  • (Apply(all displays))

Page Settings

  • Menu
    • Click "No menu" next to menu
    • [x] Normal menu entry
    • (Apply)
    • Title: Yearly Archives
    • Menu: Main menu
    • Weight: 3
  • (Apply)

Pager

  • User pager
    • Click "Full"
    • [x] Display all items
    • (Apply(all displays))
  • (Apply(all displays))
  • (Save) (Save the view)

Now, if we go to the homepage and click "Yearly Archives" we’ll see the list of all site content grouped by year.