Modifier le bloc de recherche Drupal

function mon_theme_preprocess_search_block_form(&$vars, $hook) {

  // Modify elements of the search form
  unset($vars['form']['search_block_form']['#title']);

  // Set a default value for the search box
  $vars['form']['search_block_form']['#value'] = t('Search');

  // Add a custom class to the search box
  $vars['form']['search_block_form']['#attributes'] =
    array(   
    'onfocus' => 'if(this.value == \''.t('Search').'\') {this.value = \'\';}',
    'onblur' => 'if(this.value == \'\') {this.value = \''.t('Search').'\';}');

  // Change the text on the submit button
  $vars['form']['submit']['#value'] = "ok";

  // Rebuild the rendered version (search form only, rest remains unchanged)
  unset($vars['form']['search_block_form']['#printed']);
  $vars['search']['search_block_form'] = drupal_render($vars['form']['search_block_form']);

  // Rebuild the rendered version (submit button, rest remains unchanged)
  unset($vars['form']['submit']['#printed']);
  $vars['search']['submit'] = drupal_render($vars['form']['submit']);

  // Collect all form elements to make it easier to print the whole form.
  $vars['search_form'] = implode($vars['search']);
}

categorie:

Commentaires

Hello,

Est-ce que cette modification stoppe le bug d'indexation des pages recherches ?
Exemple dans Google.fr :
inurl:"search_block_form"

Merci ;)