The ideas described in this blog post have been crafted together with Letharion. Credit should go to him as much as to me. Any weird descriptions, mistakes or false tunes in this post are of my doing, though.
The module is called Views arguments in filter, and what it does is technically quite easy to describe. It allows you to configure filters in Views on the style Node: Title CONTAINS %1 or Node: Post date >= %2. (The module actually consists of only 12 lines of code, plus a bit more than that in comments.)
Using argument placeholders in filters is pretty neat, since it allows you to use operators in ways that you usually can't do with arguments – you can't for example use an arguments to show nodes published after a certain time. Operators, with few exceptions, only allow the 'equals' or 'not equals' operator – which doesn't really cover all the use cases.
But that's not the main point of this module. The main point of this module is proposing a conceptual change for how arguments are used. How?
Right now, arguments have two different functionalities in Views. The first is providing filtering capabilities, just as filters are, but with less flexibility since you can't change operators as freely – nor can you group them in and/or groups. The other functionality is to take care of an incoming piece of data, running any validations, perhaps loading node information, setting the view title and a few more things. No altering of the query.
When using the Views arguments in filters module, the first functionality can be removed. Arguments won't have to do any filtering, since that is done by the filters. This has three pretty nice implications:
- Site builders get all the flexibility of filters, even when filtering is controlled by arguments. (You can also re-use the same argument in several filters, which is currently not possible in Views.)
- Developers won't have to write close-to-identical Views handlers for both arguments and filters.
- Newcomers won't have to be as confused about arguments as they currently are. Filtering is handled by filters – period.
If you find this a sensible approach, you might want to dive into one or two. Help is always welcome, so feel free to join.
The Pony Song!
