I have a view listing a custom content type by year and quarter (Spring, Summer, Fall, Winter). It's currently listed in a table. I'd like there to be dividers for each year within the table. Simply a row that names the year before going on to the content that fits within that year. Below is an image of the effect I want to achieve.

enter image description here

I've considered creating a twig template for the view, but I'm not sure how I would be able to check whether an item is the first or last item in a year. I've also considered adding a 'custom text' field but again I'm not sure how I'd make a conditional for that, and I'm not sure how I would be able to turn that into a unique row.

Is there a way to create row dividers in a table view once the year changes, or with any field for that matter?


3 Answers 3


Matt, I have done this and giving you exact idea. I did a task for display node under specific location as you need year.

  1. I created taxonomy for location like enter image description here So if you want to create taxonomy for years and add terms it's upto you.
  2. Attach the taxonomy to node as term reference field type.
  3. Create a view of that content and add required fields. enter image description here
  4. Check view format setting set the field for grouping . enter image description here

You can use "Grouping field" option inside view formate settings for year field. Here is example of grouping

1. https://stackoverflow.com/questions/13828952/drupal-7-views-list-group-by-field?answertab=active#tab-top

2. https://www.drupal.org/node/1578512


the easiest way to achieve this is by using the Settings option from Format: Table | Settings.

Please click on the Settings and that will allow you to select the field on which you can group the results. But prior to that, you will need to add the respective date field in the fields section of the view.

Add the Date field respective to which you need to group the content. Set the format of the date to be year only, and also select exclude from display. Further, if you need to display the date in the rows also, select the same field again and set the desired format of the date.

Now, all the fields will be available for grouping in the Settings tab. You can now identify and select the date field which was formatted as year only to get the desired result.

If required, please check a simple reference blog or this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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