DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:simplegooglesearch

Replace DokuWiki search with Google search

Replace the function tpl_searchform($ajax=true,$autocomplete=true) in /inc/template.php

  function tpl_searchform($ajax=true,$autocomplete=true){
  global $lang;
  global $ACT;
 
  // don't print the search form if search action has been disabled
  if (!actionOk('search')) return false;
 
  print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">';
  print '<input type="hidden" name="do" value="search" />';
  print '<input type="text" ';
  if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" ';
  if(!$autocomplete) print 'autocomplete="off" ';
  print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[ALT+F]" />';
  print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />';
  if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>';
  print '</div></form>';
  return true;
}

using the codes below

/* Google search */
function tpl_searchform($ajax=true,$autocomplete=true){
  // don't print the search form if search action has been disabled
  if (!actionOk('search')) return false;
 
  print '<form method="get" action="http://www.google.com/custom" class="search"  id="dw__search" target="_top"><div class="no">';
  print '<label for="sbi" style="display: none">Enter your search terms</label>';
  print '<input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input>';
  print '<input type="hidden" name="domains" value="statisticalexperts.com"></input>';
  print '<input type="hidden" name="sitesearch" value="statisticalexperts.com"></input>';
  print '<label for="sbb" style="display: none">Submit search form</label>';
  print '<input type="submit" name="sa" value="Search" id="sbb"></input>';
  print '<input type="hidden" name="client" value="pub-0981582256507874"></input>';
  print '<input type="hidden" name="forid" value="1"></input>';
  print '<input type="hidden" name="ie" value="ISO-8859-1"></input>';
  print '<input type="hidden" name="oe" value="ISO-8859-1"></input>';
  print '<input type="hidden" name="safe" value="active"></input>';
  print '<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input>';
  print '<input type="hidden" name="hl" value="en"></input>';
  print '</div></form>'; 
  return true;
}

You could change two things. First change the domain name statisticalexperts.com to yours. Second, if you have a Google Adsense account, change the value pub-0981582256507874 to yours, too.

tips/simplegooglesearch.txt · Last modified: 2023-01-09 08:14 by saggi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki