How to add a web search box to the navigation bar

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search


MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins, Researchers +/-

Having a web search box on your Main Page helps to encourage users to use your wiki as their start page.

One way to do this is to modify the skin. The skins are defined under your-web-root-directory/wiki/skins. The default is Monobook, found in MonoBook.php. Although the skin definition is a PHP file don't let this scare you off. Most of the file is just HTML code. If you stick to that part you should be fine.

To add a Google search box, find the <div> element containing the existing search box and add the following <div> element underneath it.

        <div id="p-search" class="portlet">
          <h5><label for="searchInput">Google search</label></h5>
          <div class="pBody">
            <form name="searchform" action="http://www.google.com/search">
              <input name="ie" value="UTF-8" type="hidden"/>
              <input name="oe" value="UTF-8" type="hidden"/>
              <input id="searchInput" name="q" type="text"/>
              <input type="submit" name="go" class="searchButton"
                id="searchGoButton" value="Google"/>
            </form>
          </div>
        </div>

To edit the navigation bar see Manual:Navigation bar.