1

I am trying to create a calendar-type view that will display links to specific nodes during certain months of the year. For example, this would show 'Taxes' in Feb and April, 'Travel' from May to September, etc.

So far I have added a boolean field to my node to appear in the view, but I am stuck on how to implement the date selector. Theoretically I would like to have people select the months that this node should appear in the view, and the view will contextually display the nodes depending on the current month.

The problems I'm running into are:

  • The date field seems to require a year, but I want this to be year agnostic
  • The date field doesn't allow selection of multiple months

I am thinking that I will have to use a date field so that I can use contextual filters to display based on month of the year. I don't have access to the codebase so I need to do all of this within the UI using modules, if possible.

Any tips on how I can achieve this?

0

Here's an idea for something you could do in the Drupal admin UI (using only modules that are part of Drupal 8 core) since it seems you don't have access to the codebase.

As you noted, the date field requires a year. So you can't use it if you want your months to be year-agnostic.

I assume that your requirement is "each node should be assigned to one or more months" and we don't have to worry about days (for example, a node could be "January and February", but it could not be "Jan 12 - Feb 10").

In that case, you can add a field of type List (Text) to the node content type that you want to sort in Views. For the value of the field, enter the 12 months and allow multiple values so that multiple months can be selected.

Then, you can configure the view to filter based on your month field. To set the current month, I'm pretty sure you can use Twig date in a Views filter to input the current month (not tested, from memory).

1
  • The last part is where I am having trouble - how do I configure a filter to 'input' the current month and compare it to the field? Using Contextual Filters? If so, how?
    – SkunkDog
    Jan 14 at 17:12

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.