2

I have a view which lists products. I created an exposed filter based on price criteria.

The exposed filter shows a text input where you can type an integer number to get the products filtered. What I need is to replace the text input with a select list showing values such as 50000, 100000, 1500000, 200000.

I have the Better Exposed Filters module, and the Views PHP module enabled.

screenshot

0

If you're using Better Exposed Filters, you can go to the edit page for the view (from /admin/structure/views). Then selected Better Exposed Filters for the Exposed form style which is under EXPOSED FORM.

Next click BEF Settings, scroll down to Exposed Filter Settings, and choose Display "Price is higher than" as Select list. If you don't have the option for select list, the Better Exposed Filters module won't be able to help you.

  • No, I don't have the 'Select list' option. Why? What can I do to have this option available? – chefnelone Apr 4 '12 at 9:51
  • What type of field is it? Integer? List (integer)? – Patrick Kenny Apr 4 '12 at 9:57
  • It is a Integer field type. – chefnelone Apr 4 '12 at 10:34
  • Can you use a list (integer) or is that impossible for your use case? If you re-create the type as a list integer, you'll be able to display it as a select list with no problem-- however, you will have to choose all values from the list and will no longer be able to input values freely. – Patrick Kenny Apr 4 '12 at 10:42
  • I see. I need to be able to freely set these values. What about programmatically? I found this article drupal.org/node/766974 but not sure if I will find the solution... – chefnelone Apr 4 '12 at 10:46
1

Edit View >> Configure filter criterion >> Select grouped filter (instead of the default, single filter) >> Set-up your options. That's it! you now have dropdown filters of free filled node field.

0

I came across the situation as well. As a quick "hack" you can do the following:

  1. expose your filter as a text field, just like you show above
  2. copy and paste the HTML output of that filter (everything between < FORM ... and < /FORM> tags
  3. add the HTML in the view's "header" as "global text area", make sure you select a text filter that allows FORM and SELECT tags
  4. replace the < INPUT ..> tag with a < SELECT> tag (keep the name=... value the same)
  5. add your < OPTION> tags, use value="" if you want an "Show all" option
  6. hide the exposed filter by setting "exposed form in a block" to yes

Now you'll have a select list instead of an input box. You could probably add a bit of jquery magic if you want to preselect the option.

If you have a lot of options you could probably even use another view to generate the < OPTION> tags using rewrites. However, I haven't tried that one.

0

Use this module: Views Reference Filter

You create a separate view (or a new display of the same view) which returns the list of items to show in drop down select list of the exposed filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.