Jump to content

Extension talk:Google

Add topic
From mediawiki.org
Latest comment: 14 years ago by 83.142.1.165 in topic Google
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

This is for a generic Google searchbox. How can we get a site-specific search query in there? Thanks!

[edit]
# Sintaxe: <google>SearchTerm<google/>
$output .= '<input type="text" name="q" size="25" maxlength="255" value="'. $1 .'"/>';

This makes the extension more usable for me, still keeping downward compatibility.

For Example: I created a page "WikiMedia:ExtendedSearch" with <google>$1</google> to include it within my results page (per includes/SpecialSearch.php). So there is a google-search with a preset search-term. see FAQ How do I add search engines ...

--Sascha

The above code didn't quite work for me. I checked here Manual:Tag extensions and properly integrated the equivelent change with the code below. --Dmb 15:48, 24 April 2008 (UTC)Reply


Site specific?

[edit]

Here is the code, --Dmb 13:57, 28 September 2007 (UTC)Reply

<?php

$wgExtensionFunctions[] = "wfGoogleSearch";

$wgExtensionCredits['parserhook'][] =
  array(
        'name'        => 'GoogleSearch',
        'author'      => array( 'The MediaWiki Community', 'Dan Bolser' ),
        'url'         => 'http://www.mediawiki.org/wiki/Extension:Google',
        'description' => 'Allow inclusion of a Google Search.',
        );

function wfGoogleSearch() {
  global $wgParser;

  $wgParser->setHook( "googleSearch", "wfRenderGoogleSearch" );
}

# The callback function for converting the input text to HTML output                                                                    
function wfRenderGoogleSearch( $input, $params, $parser ) {
  $output  = '<!-- Search Google -->';
  $output .= '<center>';
  $output .= '<form method="GET" action="http://www.google.com/search">';
  $output .= '  <table>';
  $output .= '    <tr>';
  $output .= '      <td>';
  $output .= '        <a href="http://www.google.com/">';
  $output .= '          <img src="http://www.google.com/logos/Logo_40wht.gif" ';
  $output .= '           border="0" alt="Google" align="absmiddle"/>';
  $output .= '        </a>';
  $output .= '      </td><td>';
  $output .= '        <input type="text" name="q" size="25" maxlength="255" value="'. $input. '"/>';
  $output .= '        <input type="submit" value="Google Search"/>';
  $output .= '      </td>';
  $output .= '    </tr><tr>';
  $output .= '      <td> <!-- A blank cell -->';
  $output .= '      </td><td>';
  $output .= '        Search:';
  $output .= '        <input type="radio" name="sitesearch" value=""/>The Web';
  $output .= '        <input type="radio" name="sitesearch" value="biodatabase.org" checked/>MetaBase';
  $output .= '      </td>';
  $output .= '    </tr>';
  $output .= '  </table>';
  $output .= '</form>';
  $output .= '</center>';
  $output .= '<!-- Search Google -->';
  return $output;
}

TODO

[edit]
  • Alter the above to pick up the site name and base URL using MW parameters instead of the hard coded values.
  • Be bold and replace the version on the extension page with this version.
  • Get this into the MW SVN?

Google

[edit]

What is Google? 83.142.1.165 18:43, 25 October 2010 (UTC)I´m a IP-adress from SwedenReply

[edit]

Hello,

 I have  a google mini search appliance that I use to index my wiki.
How can I replace or add a search box in my wiki to use my mini search and not wiki search.

Thanks