Change the Search Header in Zen Cart


The search_header.php sidebox is specifically designed to display a search box in your Zen Cart header.  Unfortunately in a default installation of Zen Cart the phrase ‘Enter search keywords here’ does not completely fit into the input field, as shown here:

Zen Cart - Search Header

There are two options to address this – either shorten the phrase to something that can be shown in full or increase the size of the input box.  Step-by-step guides for both options are provided below.

Shorten the search header default phrase

  1. Open the header.php file located in the /includes/languages/english directory.
  2. Find this section of code:
    // header Search Button/Box Search Button      <br />define('HEADER_SEARCH_BUTTON','Search');      <br />define('HEADER_SEARCH_DEFAULT_TEXT', 'Enter search keywords here');
  3. and modify the define statement as needed:
    // header Search Button/Box Search Button      <br />define('HEADER_SEARCH_BUTTON','Search');      <br />define('HEADER_SEARCH_DEFAULT_TEXT', 'Enter keywords');

    ** Be sure to keep the single quote marks in your new define statement.

  4. Save the modified english.php file to your override folder.  This will be /includes/languages/english/CUSTOM/ where CUSTOM represents the name of your current template folder.

Shorten the search header default phrase

Increase the size of the search header input box

  1. Open the tpl_search_header.php file located in the /includes/templates/template_default/sideboxes/ directory.
  2. Find this section of code:
    if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') {
     $content .= zen_draw_input_field('keyword', '', 'size="6" maxlength="30" style="width: 100px" value="' . HEADER_SEARCH_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . HEADER_SEARCH_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . HEADER_SEARCH_DEFAULT_TEXT . '\';"') . '&nbsp;' . zen_image_submit (BUTTON_IMAGE_SEARCH,HEADER_SEARCH_BUTTON);
     } else {
     $content .= zen_draw_input_field('keyword', '', 'size="6" maxlength="30" style="width: 100px" value="' . HEADER_SEARCH_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . HEADER_SEARCH_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . HEADER_SEARCH_DEFAULT_TEXT . '\';"') . '&nbsp;<input type="submit" value="' . HEADER_SEARCH_BUTTON . '" style="width: 45px" />';
     }
  3. and modify the define statement as needed (in this example I’ve used 170px for the length):
    if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') {
     $content .= zen_draw_input_field('keyword', '', 'size="6" maxlength="30" style="width: 170px" value="' . HEADER_SEARCH_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . HEADER_SEARCH_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . HEADER_SEARCH_DEFAULT_TEXT . '\';"') . '&nbsp;' . zen_image_submit (BUTTON_IMAGE_SEARCH,HEADER_SEARCH_BUTTON);
     } else {
     $content .= zen_draw_input_field('keyword', '', 'size="6" maxlength="30" style="width: 170px" value="' . HEADER_SEARCH_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . HEADER_SEARCH_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . HEADER_SEARCH_DEFAULT_TEXT . '\';"') . '&nbsp;<input type="submit" value="' . HEADER_SEARCH_BUTTON . '" style="width: 45px" />';
     }
  4. Save the modified tpl_search_header.php file to your override folder.  This will be /includes/templates/CUSTOM/sideboxes where CUSTOM represents the name of your current template folder.

Increase the size of the search header input box

     
   
     

More Zen Cart:

  1. Display Advanced Search on ‘Page Not Found’ page in Zen Cart
  2. Display a Search Box on ‘Page Not Found’ page in Zen Cart
  3. Track your visitors’ search actions in Zen Cart
  4. Change name of More Information sidebox Heading in Zen Cart
  5. Change name of Page 2 Link in More Information Sidebox
  1. No comments yet.
(will not be published)

Notify me of followup comments via e-mail. You can also subscribe without commenting.