Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Implements hook_block_view().
- function customsearch_block_view($delta = '') {
- if (user_access('search content')) {
- $block['content'] = drupal_get_form('customsearch_block_form');
- return $block;
- }
- }
- // Implements hook_forms().
- function customsearch_forms() {
- $forms['customsearch_block_form']= array(
- 'callback' => 'customsearch_box',
- 'callback arguments' => array('customsearch_block_form'),
- );
- return $forms;
- }
- // Form builder; Output a search form for the search block's search box.
- function customsearch_box($form, &$form_state, $form_id) {
- $form['customsearch_form'] = array(
- '#type' => 'textfield',
- '#title' => '',
- '#title_display' => 'invisible',
- '#default_value' => '',
- '#attributes' => array(
- 'title' => t('Search the website'),
- 'placeholder' => t('search the website'),
- ),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
- // define function to determine search destination
- $form['#submit'] = array('customsearch_search_box_form_submit');
- return $form;
- }
- // overide submission of search query from block
- function customsearch_search_box_form_submit($form, &$form_state) {
- $searchterm = $form_state['values']['plus_search_form'];
- $search_path = 'specialcustomsearch'// replace with the path to your search results page
- // pass search term to your search results page as argument
- drupal_goto($searchpath .'/'. $searchterm);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement