0

I have several content types with Date fields. I would like to build a View that groups that content by our academic year, e.g. 2015-2016, 2016-2017, 2017-2018, etc.

I realize I would have to define those start and end dates somewhere (i.e. August 1 through July 31). It could be similar to a fiscal year as well.

I could do taxonomy terms, but I was hoping to not have to introduce another field if the date fields can accomplish this.

I am using Drupal 8.

0

Use Grouped Exposed Filter

Using a Grouped Exposed Filter for the Authored on field is the quickest and easiest way to filter out by academic year.

When you Expose a Filter, you can choose between Single filter and Grouped filters:

grouped Exposed Filter

If you choose Grouped filters you can define your own items for the Exposed filter. In your case two academic years would be configured like this:

Academic year grouped exposed filter

I haven't included time but you probably should to make sure that content created on July 31 and August 1 doesn't get exluded. Maybe something like 2017-08-01 00:00:00 and 2018-07-31 23:59:59 would work.

Add as many entries as you have academic years. Then when viewing your Views results choose the appropriate academic year option:

academic year exposed grouped filter

I've noticed grouped filters have some bugs in D8 when dealing with taxonomy terms, but I haven't noticed any problems with AuthoredOn field.


Contextual Filter Content: Created year + month

If you include this Contextual Filter and choose to Display a summary:

Contextual Created on Year + Month

you get links of months and years you click through to see content posted within those dates:

created Year + Month Contextual

If that alone isn't enough maybe that can inspire you to create a similar custom Contextual filter with a bit more logic inside to do the same but for a configurable set of periods.

  • Thanks. Between both of those, it's close to what I want, but I'm not looking to filter -- only to group. I may be able to work up something similar with a custom field and group on that. – MrPeanut Jun 20 '18 at 19:43
  • A custom solution will give you the most flexibility. If you don't know how and can't afford it and there aren't that many years to deal with, you can create an attachment for each academic year and display them one below the other on a page ;) – prkos Jun 21 '18 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.