Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:17:21+00:00 2026-06-03T03:17:21+00:00

I have a view I’m using as an Advanced Search tool – it simply

  • 0

I have a view I’m using as an “Advanced Search” tool – it simply provides a list of relevant nodes which are limited by a number of exposed filters I have in place. In particular, I have a “keyword” exposed filter that’s acting as the main search box, which filters on the node title. Now, I’ve had a request for the ability to toggle (I assume with a checkbox or similar) this filter to search on both the node title and body at the same time, as an option to provide users with more search results.

I currently have a view set up with two displays: one that filters on just the node title, and one that uses Views Or to limit the results to nodes that have the keywords in either the node title OR the node body. By themselves, both of these displays are working the way I’d like.

My question is how I’d go about toggling between these two displays using a checkbox or something similar. I don’t want to use Views Display Tabs because both displays look visually identical (the only difference is how the filters are configured to include more/less results) which would be confusing to the user – plus it uses AJAX which breaks some (mostly small) modifications I’ve made via jQuery to the behavior of the view.

What I’d like to accomplish, in essence, is a conditional check when the view is submitted – depending on whether a checkbox is selected, the arguments are sent to one display or the other. Any suggestions on how to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:17:22+00:00Added an answer on June 3, 2026 at 3:17 am

    One way you might be able to go about this could involve adding a custom validate handler on the exposed filter form that would in theory allow you to check the value and forward the request to a different page display appropriately. Exposed filters are exposed in the URL as $_GET variables, so, forwarding a user to a specific page with filters predefined should be easy enough.

    <?php
    
    function mymodule_form_alter(&$form, $form_state, $form_id) {
      switch ($form_id) {
        case 'views_exposed_form':
          // Deterimine the ID so you only do this
          // to a specific exposed filter form
          // drupal_set_message($form['#id']);
          if ($form['#id'] == 'views-exposed-form-api-search-page-1') {
            // You might also want to add the checkbox FAPI item in this area
            $form['#validate'][] = 'mymodule_api_search_validate'; // custom validate handler function name
          }
        break;
      }
    }
    
    function mymodule_api_search_validate($form, &$form_state) {
      // Check if the FAPI item has the specified checkbox value
      if ($form_state['values']['options'] == 'title') {
        // The get variables to pass to the views exposed filters
        // You can configure what this $_GET variable should be while editing the filter
        $query = array(
          'query' => 'the search query',
        );
        drupal_goto('api/search', $query);
      }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC 2, I have view which simply displays label with current
i have view which looks something like this : <% using (Ajax.BeginForm(new AjaxOptions {
i have view controller which contains a button which show the image library ,if
I have view.jsp and edit.jsp pages. Both call load() method of an action, which
I have view which contains a scrollView. When the view shows up the image
I have view controller which is inherited from UINavigationController . On viewDidLoad I want
I have view controller, and inside I have IBOutlet UITextField *title , which is
I have view for which it only makes sense to use a certain ordering.
i have a view in which i have table view and when user taps
i have view like 'home/details/5', it can be access by anonymous user. but there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.