I have couple hundreds of articles on a website. I use a view to show excerpts and links to them on one page and I also have a pager that show 10 articles at the time. I need to add a dropdown with years [...,2008,2009...,2013]. If you select a year in the dropdown, then view should only display articles that were posted in that year. Years in the dropdown should be updated automatically if a new article added in 2013 for example, and thus the first year is the year of the first publication.
Please suggest possible solutions.
Here is a way to do it if you want to use Drupal's built in "Authored on" field for a node. You'll need to create a custom module. This was created in Drupal 7 / Views 3. My module files are in /sites/all/modules/custom/ViewsYearFilter/.
ViewsYearFilter.info
ViewsYearFilter.module
ViewsYearFilter.views.inc
ViewsYearFilter.inc
Then, in your view config page you can create a new exposed filter:
Sorry, but I can't actually post this image as I don't have enough reputation. There will be a new exposed filter named "Content: Year" you can add to your view after creating and activating your new module.
PS: I based my code off of Shevchuk's answer on this question.
I think, you need to set exposed filter to the view list. The configuration should be something like--
Inform me if it works..