Add search block overrides

japerry - April 15, 2009 - 23:06
Project:Google Search Appliance
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:japerry
Status:needs review
Description

It'd be nice to have the ability for the search block to default to the GSA instead of normal drupal search. Below are some code snipets that will allow the module to do this:

Edit 'google_appliance_form_alter' and add the function here below it....

    .. // I changed the form_alter function to use case statements instead of else-if.. so take note.
    case 'search_block_form':
      if (variable_get('google_appliance_control_search',false)) {
        $form['#submit'][] = 'google_appliance_search_block_form_submit';
      }
      break;    
  }
}

function google_appliance_search_block_form_submit($form, &$form_state) {
  $form_id = $form['form_id']['#value'];
  $form_state['redirect'] = 'search/google_appliance/'. trim($form_state['values'][$form_id]);
}

#1

brandon.dixon - May 28, 2009 - 15:58

Id really like to add this to my current module. Could you elaborate more on where to put the first part of your code. I understand to edit the module file and find the form_alter function, but do I keep the existing code there and just paste yours in or delete it all out?

 
 

Drupal is a registered trademark of Dries Buytaert.