hi, is there any plans to be able to remove the 'colon' after the 'Search this site' text. I was hoping this module would have provided it.

*goes back to the ranks of people who are frustrated with core search block*

Comments

jweberg’s picture

This module does provide that. You can actually change that text to whatever you want.

milos1234’s picture

strange, because when i change the text, the colon remains

ie drupal default = "Search this site:"
change text to "Custom search text"
result = "Custom search text:"

jweberg’s picture

Is anyone else having this issue?

jweberg’s picture

I just tested this on one of my sites, and it did happen. Don't know how I missed it before. Not sure how to fix this. I'll look into it.

jweberg’s picture

It appears that the reason the colon is there is because the field is a label. I'm not sure if this is something I want to fix. It currently just adds a field to the label of the form. To change this I would have to change the form. Most people leave that field blank and use the default text instead.

jweberg’s picture

Status: Active » Closed (won't fix)
netsensei’s picture

You should take a look in form.inc: theme_form_element() themes the form element (input/select/... + label). You'll notice this line:

$output .= ' <label for="'. $element['#id'] .'">'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";

You could override this function in your own template.php. Next you want to change the '!title: !required' part and remove the colon. Beware though: this breaks gettext support because most translation packages are generated against the default '!title: !required' string.

akalata’s picture

If you want your search box label to already have punctuation, and not a colon after that ("What?" instead of "What?:"), you can use the theme function described at http://drupal.org/node/376345#comment-1743344.

I was also able to quickly adapt that theme function with an extra if statement to check if the label text matches the text you've specified in the Custom Search Box settings box. Of course, this means that any labels with that text will be treated the same, so this might not be your ideal solution:

function yourthemename_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();
 
  $str = $element['#title'];

  // added IF statement to match Custom Text Box string
  if ($str=='Search') { $pun = " ";}

  else {
  // Get the last character of a string - needed to determine if the last character is punctuation or not.
  $last = $str[strlen($str)-1];
  switch ($last){
    case "?":
      $pun = " ";
      break;
    case ":":
      $pun = " ";
      break;
    case ".":
      $pun = " ";
      break;
    default:
      $pun = ":";
   }
  } 
	
  $output = '<div class="form-item"';
  if (!empty($element['#id'])) {
    $output .= ' id="'. $element['#id'] .'-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="'. $t('This field is required.') .'">*</span>' : '';

  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= ' <label for="'. $element['#id'] .'">'. $t('!title'. $pun .'!required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
    }
    else {
      $output .= ' <label>'. $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
    }
  }

  $output .= " $value\n";

  if (!empty($element['#description'])) {
    $output .= ' <div class="description">'. $element['#description'] ."</div>\n";
  }

  $output .= "</div>\n";

  return $output;
}
DreeStyler’s picture

#7 -> Nice one!
Simple, functioning.

DreeStyler’s picture