Combine two or more filter criteria in views I want to combine two or more filter criteria to a dropdown in views filter criteria. so that i can select a filter criteria in the dropdown box and can search with a string in a text box. so that the result will be similar to the string from the filter criteria which is selected from the dropdown listbox(combination of filter criterias).

Is there any way to combine the filter criteria as dropdown...?
I Found this problem interesting and spend little time over this. Here is the solution i come with.


Create a view with title and Body field.
Add two filters Content:Title and Content:Body with Contains operator, expose these two filters.
Create a custom module with the following hooks.

//custom.module
function custom_form_views_exposed_form_alter(&amp;$form, &amp;$form_state, $form_id) {

if ($form_id == 'views_exposed_form' &amp;&amp; $form_state['view']-&gt;name == 'VIEW_NAME') {

    // Unset the title and body filter info so that it doesn't print any label.
    unset($form['#info']['filter-title']);
    unset($form['#info']['filter-body_value']);
    // Unset the title and body filter
    unset($form['title']);
    unset($form['body_value']); 

    $form_element = array();
    $options = array(
    // '' =&gt; '-Select-',
      'title' =&gt; 'Title',
      'body' =&gt; 'Body',
    );
    $form_element['search_within'] = array(
      '#type' =&gt; 'select',
      '#title' =&gt; t('Search within'),
      '#options' =&gt; $options,
      '#default_value' =&gt; !empty($form_state['search_within']) ? $form_state['search_within'] : '',
      '#description' =&gt; t('Set the &lt;em&gt;Title&lt;/em&gt; or &lt;em&gt;Body&lt;/em&gt; within which you want to search.'),
      '#prefix' =&gt; '&lt;div class="views-exposed-widget"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
    );
    $form_element['search_box'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; t('Search term'),
      '#default_value' =&gt; !empty($form_state['search_box']) ? $form_state['search_box'] : '',
      '#description' =&gt; t('Enter the term which you want to search.'),
      '#prefix' =&gt; '&lt;div class="views-exposed-widget"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
    );
    $form = $form_element + $form;
}
}

function custom_views_query_alter(&amp;$view, &amp;$query) {
if ($view-&gt;name == 'VIEWS_NAME') {
    if (!empty($view-&gt;exposed_input['search_box']) &amp;&amp; $view-&gt;exposed_input['search_within'] == 'title') {
    // Add title filter condition if title is selected
        $query-&gt;where[1]['conditions'][] = array(
          'field' =&gt; 'node.title',
          'value' =&gt; '%' . $view-&gt;exposed_input['search_box'] . '%',
          'operator' =&gt; 'LIKE',
          );
    }
    if (!empty($view-&gt;exposed_input['search_box']) &amp;&amp; $view-&gt;exposed_input['search_within'] == 'body') {
    // Create join with fiedl_data_body table.
    // source:
    // https://api.drupal.org/api/views/includes!handlers.inc/function/views_join%3a%3aconstruct/
    // https://www.drupal.org/node/2049051#comment-7784967
        $join = new views_join;
        $extra = array();
        $extra[] = array(
          'table' =&gt; 'field_data_body',
          'field' =&gt; 'entity_type',
          'value' =&gt; 'node',
          'operator' =&gt; '=',
          );
        $extra[] = array(
          'table' =&gt; 'field_data_body',
          'field' =&gt; 'deleted',
          'value' =&gt; '0',
          'operator' =&gt; '=',
          );
        $join-&gt;construct('field_data_body', 'node', 'nid', 'entity_id', $extra);
    // Add join to query; 'node' is the left table name
        $view-&gt;query-&gt;add_relationship('field_data_body',$join,'node');
    // Add fields from table (or where clause, or whatever)
        $view-&gt;query-&gt;add_field('field_data_body','entity_id');
    // Add body filter condition if body is selected
        $query-&gt;where[1]['conditions'][] = array(
          'field' =&gt; 'field_data_body.body_value',
          'value' =&gt; '%' . $view-&gt;exposed_input['search_box'] . '%',
          'operator' =&gt; 'LIKE',
          );
    }
}
}


Note: This solution will only work with Contains operator and very case specific. It would be great if somebody will create a generic views filter handler to combine exposed filter as select list and allow search within selected filter.