On my site, users can input their nationality in a field provided by the Countries module. About half the users on my site are Japanese, and the other half come from all other countries.
I have a view that allows members to search for each other, and I want to make the nationality an exposed filter. Since there are 200+ countries in the world, I do not want to expose the entire list of countries (this would be a selection nightmare on mobile phones).
Instead, I would like to provide a select list with three options: All countries, Japan, and Not Japan.
The Views UI allows administrators to select options on select lists and limit the list to the selected options by checking a box. This is not what I want to do, because there is no way to create a Not Japan option (which should show all members from all countries except Japan).
This answer suggests writing a custom views filter handler, but I'm a bit confused about where to begin.
The Countries module provides its own custom handlers, but (I think) these are overkill for what I need (you have to add a relationship to the country, which allows you to filter by continent, etc.); I simply need to make a version of the basic select list handler with my three options.
It seems that most views handlers extend another. In the views/handlers
folder there is a file, views_handler_filter_string.inc
, which I think I can use, but I'm not really sure what the next step is to take.