Do not execute a view if exposed filters are empty

When using a view with exposed filters, if the exposed filter is empty, by default views renders the view with all results displayed. To make an empty view instead :

  • Add an argument "Global: Null"
  • Action to take if argument is not present: Provide default argument
  • Default argument type: Fixed entry
  • Default argument: let it blank
  • Validator: PHP code
  • PHP validate code:
    if (!empty($view->exposed_input) && count($view->exposed_input) == 1 && isset($view->exposed_input['destination'])) {
    return FALSE;
    }
    return (!empty($view->exposed_input));
  • Action to take if argument does not validate: Display empty text (if you want the view to be rendered)

And voilà !