Submitted by admin on Thu, 04/09/2020 - 10:19

For Drupal 7, Views grouping and rewriting has been easy due to easy retrieval and controls of tokens. On D8, this gets tricky for the Date Views. If you have a set-up similar to this, the steps in the subsequent section might help:
Requirements: Events Listing page
- Show generic events listing, for example by event title, date, description in a tabular display (used Bootstrap responsive table)
Column groupings have no issue as default Views field order can be controlled in the table format settings - Further Group events by Month and Year - an example is to show a heading before the grouped event rows as "January 2020", under which are listed grouped nodes or event content items with dates under that month, and so on and so forth
Tricky as the table or group settings does not provide any way to do this easily
Solutions/Workaround
Make use of another field custom-date formatted as Month + Year, hide this from the display, and use this for the grouping under the table format settings. Steps below:
- Download and install https://www.drupal.org/project/date_group, we will need this later
- Create a View for the Events listing, will work either as Page or Block view
- Setup the format, fields to display as needed, e.g. Event Title, Date/s, Body, etc.
- Important to set format as a table, e.g. Bootstrap Table or any Table formats, necessary to have a nice columnar view
- Create another date field: Custom Date format for Month and Year only, to be used as format for the grouping later, hide this (do not display field), and set this field's display format to Date Group (this formatter provided by the additional module installed)
- Go back to Table settings, then group the hidden field. This will now group your content items accordingly
Screenshots of Steps
Display Output of Event calendar items grouped by Month and Year
Leave a Comment