Numeric, alphabetical and list ranges are all supported. Node ids, user ids and even taxonomy term ids are all special cases of numbers so will work also. Range-filtering on dates is also supported. For this you may use either the absolute date format as dictated by Views, YYYYMMDD, or the relative format, which supports natural language phrases like six months ago, today noon and even first Tuesday of November.
Please be aware that contextual filters are different from exposed filters. This module is about contextual filters only.
You may use the OR operator (i.e. +) and the negate operator. You negate by ticking the "Exclude" box on the Views Contextual filter configuration panel, in the "More" section.
If you run PHP version 5.3.9 or later use the latest version of this module. Otherwise go for 7.x-1.1.
To create a contextual range filter, first create in the Views UI a plain contextual filter, as per normal. Then visit the Contextual Range Filter configuration page .../admin/config/content/contextual-range-filter (2nd picture, click to enlarge), find your contextual filter name and tick the box next to it to turn it into a contextual range filter.
Just like normal contextual filter arguments, contextual range filter arguments may be set by appending them to the URL to your view. Use the double hyphen '--' as the from/to separator:
http://yoursite.com/someotherviewpath/six months ago--tomorrow noon
Alternatively, if you wish to offer your visitors a UI to enter "from" and "to" contextual filter values in textfields, install the Views Global Filter module.
For a range slider (bottom picture), also enable together with Views Global Filter the Slide with Style module from the Select with Style package. Note: Slide with Style can also be used as a widget for Views' exposed filters. You don't need Views Global Filter for that.
The README contains a number of examples of how to use contextual range filter arguments for numbers, strings and lists.
Try it yourself, live online
Want a quick demo? Follow these steps to create a D7 test site in seconds on simplytest.me.
- Click here and press "Launch sandbox". Next, press Login to enter your simplytest.me site.
- Enable the Views UI and Devel Generate modules.
- At Structure >> Views enable the View Glossary.
- On the Configuration page, under "Development", click Generate content to generate 50 or so random pages.
- Then back on the Configuration page click Views Contextual Range Filters. Tick the box in front of Title in view: Glossary.
- Visit the Glossary View, appending a contextual filter range, e.g. /glossary/d--r.
For D8 (when ready) the steps are nearly identical. But start with this link.
Q: What about ranges on date fields? By this I mean fields supplied via the Date module, as opposed to core's created and updated date properties?
A: The combo of Views together with the Date module already supports contextual date filter ranges for fields, via its submodule Date Views. So you don't need this module when you're after date ranges for fields and are happy to enter absolute dates. However, if you wish to use relative dates in your ranges and use natural phrases like 3 months ago, then you do need this module. No need to enable Date Views in that case.