0

I need to be able to show all results of my view initially but then only show 1 result after the user selects their options form the exposed filters.

1 Answer 1

0

For the record, this seems like a really odd thing to want to do! How would you narrow it down to a single result if more than one matches the filter?

Anyway, you should be able to use this hook: https://api.drupal.org/api/views/views.api.php/function/hook_views_query_alter/7

If you check for the existence of filter values, you can then apply a "LIMIT 1" to the query.

2
  • It isn't an odd request when you know the actual use-case. It's a proximity search box that allows user to see which constituency zone they are in on a map. There is only one possible answer. However they still need to see all of the zones on the map before filtering. Commented Apr 30, 2014 at 19:37
  • okay! That becomes much easier! I assume that your filters would mean they'd only end up with 1 result?
    – jdu
    Commented Apr 30, 2014 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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