Apple like accesible search field

Add to your website an Apple like search field, with rounded borders, shadows, the lens and the reset button. This solution, specific for Wordpress, is based on xhtml strict + css accessible codes, compatible with Mozilla Firefox, Apple Safari, Internet Explorer 7 and 6. You can customize graphics editing the images and localize the widget in infinite languages, thanks to php-gettext support. With few changes to the code you can use it in your non-Wordpress-based website.

The xhtml strict code

In Wordpress, edit the file /wp-includes/widgets.php, commenting the following code.

__() and _e() are for localization with gettext.

<!−−
<form id=”searchform” method=”get” action=”<?php bloginfo(‘home’); ?>”>
<div>
<input type=”text” name=”s” id=”s” size=”15″ /><br />
<input type=”submit” value=”<?php echo attribute_escape(__(‘Search’)); ?>” />
</div>
</form>
−−>

…and insert the following code:

<?php
function wp_widget_search($args) {
extract($args);
echo $before_widget;
?>
<form id=”searchform” method=”get” action=”<?php bloginfo(‘home’); ?>”>
<p>
<label for=”s”><span>
<?php _e(‘Search’); ?>
</span></label>
<input name=”s” id=”s” type=”text” accesskey=”s” />
<input type=”reset” value=”<?php _e(‘Reset’); ?>” accesskey=”r” />
<input type=”submit” value=”<?php echo attribute_escape(__(‘Search’)); ?>” />
</p>
</form>
<?php
echo $after_widget;
}
?>

The css code

Add the following cascade style sheet (css) to your theme .css file, deleting other #searchform styles, if necessary.

#searchform {
margin: 0;
padding: 0;
overflow: hidden;
}
#searchform label {
float: left;
width: 20px;
height: 19px;
background: url(media/images/search_label.gif) no-repeat;
}
#searchform label span {
visibility: hidden;
}
#searchform input[type="text"] {
float: left;
width: 120px;
height: 13px;
font-size: .9em;
border-right: none;
border-left: none;
background-color: white;
}
#searchform input[type="text"]:focus {
border-color: silver;
}
#searchform input[type="reset"] {
float: left;
border: none;
width: 19px;
height: 19px;
background: url(media/images/search_reset.gif) no-repeat;
padding-left: 20px;
margin-right: -6px;
overflow: hidden;
color: transparent;
}
#searchform input[type=reset]:active {
background: url(media/images/search_reset_hover.gif) no-repeat;
}
#searchform input[type=submit]{
display: none;
}

Tags: , ,

4 Responses to “Apple like accesible search field”

  1. Renu Says:

    I didn’t understand what changes should i make to searchform.php and widgets.php. Would you mind explaining a bit more. I love this type of search to be put in my wordpress blog.

  2. Lorenzo De Tomasi Says:

    Can you explain what’s the problem?
    Try now. I have re-edit the codes because there was a problem with comments .
    Thanks.

  3. Renu Says:

    Thanks for your reply.

    I commented the <form id=”searchform” … in searchform.php and then added the next part of the code in widgets.php. Added CSS as usual, but its not working. However the search box in your site is inspiring me to try until I make it.

  4. Renu Says:

    It says Parse error: syntax error, unexpected ‘<’ in /home/***/public_html/***/wp-includes/widgets.php on line 767 after i put your code in widgets.php.

Leave a Reply

Clients

  • AL.FA. di F. Fasoli & C. s.a.s.
  • Altroconsumo
  • Arturo Di Corinto
  • Associazione A_DJ
  • Carocci editore
  • DDA Studio legale
  • ECM Europe
  • Irtem
  • Liberius
  • Lista Bonino Pannella
  • Lunaria
  • Madotto
  • Omero Editore
  • Queenmother
  • Radicali italiani
  • Radio Popolare Roma
  • Sky Italia
  • Viaggi e Miraggi

Partners

  • Biocomunicazione
  • DDA Studio legale
  • e-text
  • Free hardware foundation
  • Frontiere Digitali
  • Liber Liber
  • Liberius
  • Radio Popolare Roma
  • Renomo
  • Unbit

Newsletter

Receive Isotype articles directly in your e-mail address, thanks to FeedBurner.

Listen to Radio popolare Roma

Da oggi Roma si sente meglio. Radio popolare Roma 103.3. Vede. Sente. Dice. Diretta 0682003666. Abbonamenti 0689929141 Abbonati online Ascolta