Display a Calendar On Taxonomy Pages In Drupal

Introduction and Requirements

Let’s say you have a content type with a date field and term reference field. This content type could be specifically for events. Because of this, you most likely would like to display this content type in a calendar format. Luckily, Drupal’s Calendar module does just that. However, if a user were to visit any of the term pages associated with that content type, they would simply get a list of content by default.

Click to expand

The above image shows the default display for a term with a date field.

In this tutorial, I will show you how to update the term page display to display a calendar of nodes with that term, rather than a list.

Click to expand

The above image shows the the same term display, this time in a calendar format.

Before we start, make sure you have the following configured:

  1. Have a content type with a date field
  2. This content type must also have a term reference field (preferably one not being used by other content types)
  3. Install the m following modules.
    1. Calendar
    2. Date
    3. Taxonomy Display
    4. Pathauto

In this tutorial my content type is called Date the date field is called field_date and my vocabulary is called Date Category.

Update Taxonomy Term Path

Update your path for the term being used in the term reference field to the following:

dates/[term:name]/month

Click to expand

If you have existing terms, you will need to delete their aliases and then bulk generate them.

Create a New Calendar Display From Template

Navigate to /admin/structure/views/add-template and create a new calendar view from template. Make sure you add a calendar using your specific date field. In my case it’s field_date.

Click to expand

  1. Name your view. I named mine Calendar Term Display

    Click to expand

  2. On the month display, add a contextual filter for Content: Has taxonomy term ID

    Click to expand

  3. Under WHEN THE FILTER VALUE IS ** NOT ** IN THE URL , configure the following:

    Click to expand

  4. Provide default value = enabled
  5. Type = Taxonomy term ID from URL
  6. Load default filter from term page = enabled
  7. Click Apply (this display)
  8. Rearrange the order of the contextual filters so that the Content: Has taxonomy term ID appears first​

    Click to expand

  9. Under PAGE SETTINGS update the path to the dates/%/month/%. This is based off of the pattern we created earlier for the term being referenced. The first % represents the term ID and the second % represents the start date.

    Click to expand

  10. Also under PAGE SETTINGS update the Menu to No menu entry

    Click to expand

  11. Under PAGER update the Link format to Pager in the settings section.

    Click to expand

    Click to expand

  12. Finally, under OTHER enable AJAX

    Click to expand

  13. Save the view

Update the Term Page Display

  1. Navigate to your vocabulary’s display settings at admin/structure/taxonomy/your_vocabulary/display
  2. Enable Taxonomy term page and click Save

    Click to expand

  3. Now click Taxonomy term page in the upper right hand corner

    Click to expand

  4. Set Term display to hidden

    Click to expand

  5. Set Associated content display to Views

    Click to expand

  6. Set the View to the view we just created (in my case it’s Calendar Term Display ), and set the View’s display to Month

    Click to expand

  7. Click Save