views:

154

answers:

4

is there a way to not display any results initially until the form has been submitted?

Also, I cant see where I can override the exposed form

+1  A: 

You can override the form with hook_form_alter in a custom module.

I don't believe there is a option in the Views UI to display nothing before selection. In your theme you could check if there is an selection, and hide the results if needed.

googletorp
+2  A: 

As @googletorp mentioned, you can override the expose form using hook_form_alter(): check out a couple examples in other questions to get an idea of how it works:

To display a blank form unless the user fills out the exposed form, you can use hook_views_query_alter() in a custom module:

function test_views_query_alter(&$view, &$query) {
  $filter_set = FALSE;

  foreach ($view->filter as $filter) {
    // Check if we've found a filter identifier that is set
    if ($filter->options['exposed'] && array_key_exists($filter->options['expose']['identifier'], $_GET)) {
      $filter_set = TRUE;
      break;
    }
  }

  // If the filter isn't set, add a WHERE clause to the query that
  // cannot be TRUE. This ensures the view returns no results.
  if (!$filter_set) {
    $query->add_where(0, 'FALSE');
  }
}
Mark Trapp
Thanks Mark, I had to adjust this a bit because the view had multiple filters and it was adding the query on the first filter and so affecting the following exposed filter. But, I got it working, cheers.. Also, a couple other things, the second part of my question, how can I theme the exposed form? And, how can I display a message for no results found?
Tim
Further to this Mark, I would like to be able to combine the exposed search field to search multiple database fields, its currently exposing 'title' but I would like say 'description' and 'address', but with just a single search field.
Tim
A: 

you can set a default filter (between the exposed ones) with a comparison that is always false.

gpilotino
A: 

If a filter is made optional in the exposed filter settings, the view should still display the results...

Sid NoParrots