Exposed Year Filter in View; date range has too many years

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
nflowers1228's picture

I have a view that has an exposed filter based on a Date field, displaying just the year. It works great, except it shows the +3-3 year range so with 2011 as the central year, the list displays years 2008-2014. Problem is, there are no articles for 2008 nor for 20014. Does anyone know how to set this so that the only years that display are the years we have news articles for? I tried changing the Date Published field "Years back and forward:" to "-1:+1" but that didn't make any difference. I'm thinking this is a default in Drupal theme? any help would be appreciated.

Comments

I don't think there is a way

hs2323's picture

I don't think there is a way in the current view filters structure to have the range be based on actual values from the database. The filters tend to be limited in that sort of way. I recommend setting it to something like -1:+0 (or however far back you need) so that it is set to the current year and goes a couple of years back.

As for the range not changing, does it show up in the views preview as not changing or just when viewing it as a page?

Thanks! I deleted the field

nflowers1228's picture

Thanks! I deleted the field and added it again, and I was able to put -4:+1 for the listing. It seems the option is only available when a date field is first added as a filter. So it's all set.

Nancy Flowers-Mangs

Thanks! I deleted the field

nflowers1228's picture

Thanks! I deleted the field and added it again, and I was able to put -4:+1 for the listing. It seems the option is only available when a date field is first added as a filter. So it's all set.

Nancy Flowers-Mangs

You should be able to click

hs2323's picture

You should be able to click the little gear icon next to the filter. That will take you to the date range listing.

Connecticut

Group categories

County or Region

Event Type

Featured Item (Admin Only)

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week