Hi,
I've set up a view exposed filter, doing the following steps :
- Create a CCK Integer field (Computed CCK Field), let's name it Doors.
- Create a view
- Create an exposed filter on this field, with the operator Between
I would like to know if there is a way to do the following :
I want to filter results where Doors is in a defined range.
The maximum extent of this range is very finite, let's say it can range from 0 to 20.
However, Views always uses 2 regular Textboxes when using exposed filters (with the Between operator).
So, is there some way to use a Select List, and still be able to use the number operators ?
Thanks for your attention,
Ask me if it isn't clear enough.
Comments
Comment #1
dawehnerIt is clear for me.
I think the cleanest way to do it, is to override the filter handler of the computed field, to support between. Sure that needs custom coding.
As alternative you could use hook_form_alter and alter the exposed form.
Then you could use hook_views_pre_query to alter the $view, and change the filters as you want.
Comment #2
artscoop commentedHi,
Thank you for your answer.
As it looks more robust to use the form_alter hook, I'm going to read the documentation about it.
(I'm not a Drupal developer but) Is it ok to add this hook in my template.php ?
Comment #3
dawehnerNo.
You can only write your hook implementation in a module.
Comment #4
merlinofchaos commentedThis would have to be provided by CCK, I think. Though I suppose it's possible that a generic patch to Views' numeric filtering could do it too. I'm a little torn. Maybe Markus should just send this back to Views, but I'll let him decide.
Comment #5
markus_petrux commentedIt seems to me this needs custom coding. Something like this, to be implemented in Views/CCK would have to include a method to define the ranges you wish for each option in the select list, and a simple Number field (or a Computed field) can only store one value.
I would follow dereine's advice in #1 here.
Comment #6
markus_petrux commentedSwitch issue status so I know I already visited this issue.
Comment #7
Bilmar commentedhello, I came across the same need and it was very easily solved with a custom module (the code I use is below)