- $IkiWiki::config{headercontent}.=qq{
-<form method="get" action="$IkiWiki::config{cgiurl}" id="searchform">
-<div>
-<input type="text" name="phrase" value="" size="16" />
-<input type="hidden" name="enc" value="UTF-8" />
-<input type="hidden" name="do" value="hyperestraier" />
-</div>
-</form>
-};
+my $form;
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+ my $page=$params{page};
+ my $template=$params{template};
+
+ # Add search box to page header.
+ if ($template->query(name => "searchform")) {
+ if (! defined $form) {
+ my $searchform = template("searchform.tmpl", blind_cache => 1);
+ $searchform->param(searchaction => $config{cgiurl});
+ $form=$searchform->output;
+ }
+
+ $template->param(searchform => $form);
+ }