I'm building a simple view to show content of X type, filtered by date. I want this view to be available via URLs like:
- /events/2012 - Show all content for this year only
- /events/2012/11 - Show all content for this year and month only
- /events/2012/11/28 - Show all content for this exact day only
These URLs form part of this section's hierarchy so the patterns are non-negotiable.
The date I'm filtering on is a date field provided by the Date module, and has an optional end date.
I've tried setting the path of the view to /events/%/%/%
, and have added three contextual filters for the date field. The granularity for each of the filters is set correctly to the respective date part for that filter.
However, none of that works; I either get all event content, regardless of year, for the year filter, or no content at all if I include the other filters.
There are several related questions (none with answers as it happens):
- https://drupal.stackexchange.com/questions/29663/contextual-filters-and-year-by-date-module
- Creating a contextual filter for a view based on month and day
- Use date as Views Contextual filters
But nothing that covers exactly what I'm looking to do.
How do I tame these contextual filters, without resorting to the PHP filter which is simply not an option? I can't believe that there's no way to do this just with the UI, it seems like one of the most obvious use-cases.
UPDATE
I tried using a filter with a granularity of month, and changed the argument to 2012-11
...and it worked.
So I think the answer is simply that the date filter handlers don't work as I expected.
;)