Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. // Implements hook_block_view().
  2. function customsearch_block_view($delta = '') {
  3. if (user_access('search content')) {
  4. $block['content'] = drupal_get_form('customsearch_block_form');
  5. return $block;
  6. }
  7. }
  8.  
  9. // Implements hook_forms().
  10. function customsearch_forms() {
  11. $forms['customsearch_block_form']= array(
  12. 'callback' => 'customsearch_box',
  13. 'callback arguments' => array('customsearch_block_form'),
  14. );
  15. return $forms;
  16. }
  17.  
  18. // Form builder; Output a search form for the search block's search box.
  19. function customsearch_box($form, &$form_state, $form_id) {
  20. $form['customsearch_form'] = array(
  21. '#type' => 'textfield',
  22. '#title' => '',
  23. '#title_display' => 'invisible',
  24. '#default_value' => '',
  25. '#attributes' => array(
  26. 'title' => t('Search the website'),
  27. 'placeholder' => t('search the website'),
  28. ),
  29. );
  30. $form['actions'] = array('#type' => 'actions');
  31. $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
  32.  
  33. // define function to determine search destination
  34. $form['#submit'] = array('customsearch_search_box_form_submit');
  35.  
  36. return $form;
  37. }
  38.  
  39. // overide submission of search query from block
  40. function customsearch_search_box_form_submit($form, &$form_state) {
  41. $searchterm = $form_state['values']['plus_search_form'];
  42. $search_path = 'specialcustomsearch'// replace with the path to your search results page
  43. // pass search term to your search results page as argument
  44. drupal_goto($searchpath .'/'. $searchterm);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement