2008-10-14 Google Custom Search Engine

For my site, I use a search box, a matching pages box, and a Google search. The trick is that we’re inside a span, and we want to use forms. Therefore I need to end the span, print the forms, and open it again, and use CSS to display them correctly:

push(@MyInitVariables, \&SearchBar);
sub SearchBar {
  my $pages = T('Matching Pages:') . ' '
    . $q->textfield({-name=>'match'});
  my $text = T('Search:').' '.$q->textfield({-name=>'search'});
  $UserGotoBar .= qq{
</span>
<!-- Search Box -->
<form class="tiny header" action="$FullUrl"><p>
$text
</p></form>
<!-- Matching Pages-->
<form class="tiny" action="$FullUrl"><p>
<input type="hidden" name="action" value="index" />
<input type="hidden" name="near" value="1" />
$pages
</p></form>
<!-- Google CSE Search Box Begins  -->
<form class="tiny" action="http://www.google.com/cse"><p>
  Google:
  <input type="hidden" name="cx" value="004774160799092323420:s9wlu0va1v0" />
  <input type="text" name="q" size="25" />
</p></form>
<!-- Google CSE Search Box Ends -->
<span>
};

CSS

/* search box in the top bar */
form.tiny, form.tiny p {
    display:inline;
    white-space:nowrap;
}
form.tiny input {
    padding:0;
    width:10ex;
    font-size:10px;
}

​#Oddmuse