I have a view with an exposed "sort by" form.

I don't know how to skip this sort if the user did not chose any sort mode.

My view has this exposed sort widget and the second sort criteria (not exposed) is by node sticky property. The problem is the view sorts the content by the first criteria, even though the user didn't chose something.

How can I change that? Thanks

  • I know how to do that for Table style plugin. Table display allows overriding normal sorting if click sorting is used.
    – kalabro
    Commented Aug 21, 2012 at 19:08

1 Answer 1


I just had this problem (well, similar) and I solved it the following way:

 * Implements hook_views_pre_build().
function MY_MODULE_views_pre_build(&$view) {
  // Trigger this only for the needed view
  if ($view->name == 'my_view_name') {
    // Check the exposed input array to see what the user submitted
    $exposed_input_arr = $view->get_exposed_input();
    // Write your exposed array checking logic here ...
    //if (empty($exposed_input_arr['field_sort_by']) || ...) {
      // Remove the sort field from the view

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.