Logo name

Media Wiki:Add a wikipedia search box from your main website or blog

From IpbWiki

  • Currently5.00/5
Jump to: navigation, search

On the main site of Wikipedia there is a search box to search the articles on their wiki, can you do this from your website or wiki? Yes you can search wikipedia from your site or even your own wiki if you have one!.

create a search.html file containing the following code:

CODE
<html>
<body>
<form action="search-redirect.php" id="searchform"><div>
   <input id="searchInput" name="search" type="text" />
   <input type='submit' name="go" class="searchButton" id="searchGoButton" value="Search" />
</div></form>
<!-- you can remove the below line if you wish, although it's appreciated if you leave it;) -->
Wiki search provided by <a href="http:/www.ipbwiki.com">IpbWiki.com</a>
</body>
</html>

(All you really need of the above code is the part between <form> and </form>)

In the same folder as search.html, create a file called search-redirect.php, copy the following code in it and customize the path to have it point to your wiki

CODE
<?php
# Author: Peter De Decker
# Help & documentation: http://www.ipbwiki.com/Media_Wiki:Add_a_wikipedia_search_box_to_your_main_website_or_blog

###############################################################
# Parametrisation, customize this!                            #
###############################################################

# set this to the same value as $wgArticlePath in your LocalSettings.php, make sure to have a trailing /
# examples:
# $path = 'http://www.ipbwiki.com/'; // search on ipbwiki, index.php is eliminated from the url here;
# $path = 'http://en.wikipedia.org/wiki/';              // search on english wikipedia
# $path = 'http://localhost/mediawiki-1.8/index.php/';  // default article naming...
$path = 'http://www.ipbwiki.com/';

###############################################################
# Actual code, wooo :)                                        #
###############################################################

$redirect_url = $path . 'Special:Search?search=' . $_GET['search'] . '&go=Go';
@header( "Location: ".$redirect_url );

?>

Enjoy user posted image

This page was last modified on 5 December 2006, at 10:39.  This page has been accessed 5,426 times.  Content is available under GNU Free Documentation License 1.2Disclaimers