Q: How can I create a Knowledge Base search box on my web site?
- How can I create a Knowledge Base search box on my web site?
- Can I put a search box on my wikis.mit.edu site that searches the Knowledge Base?
- I have information on my own site and in the knowledge base; can I search both?
Context
- Knowledge Base IT knowledge base and help system
- Searching the Knowledge Base
- Web page authors and site administrators
Answer
Background
- The Knowledge Base uses a special wiki page called "Ask" for its search form, and a special wiki page called "Search Results" for displaying results
- The "Search Results" page accepts properly configured HTTP GET requests (search terms encoded in the URL) from any site so a Knowledge Base search box can be included on your own web site or web page
- Several hidden form fields should be included to configure standard, required parameters
Required parameters
The following parameters should always be set as follows or your search will not work as expected:
Paramter | Value |
---|---|
searchSpaces | ist,istcontrib,istdraft,mitcontrib,hd,handbook,glossary |
resultPage | Search+Results |
resultSpace | home |
If you think you know how to change those parameters to have The Knowledge Base do something different, please don't. They don't necessarily work the way you'd expect them to. Please contact the Knowledge Base team if you plan to do something funky. See How do I contact the The Knowledge Base team? for more.
Sample HTML to include a knowledge base search box
The below HTML code will insert a very simple web form in your web page with a 60-character wide text box and a submit button that can be used to enter a search term and then submit that term to the knowledge base. It is configured to open a new browser window or tab for the results, which may be a setting you want to keep for your site so users do not lose the window to your web site after submitting the form. (The back button will also work after they end up on the knowledge base search results screen.)
<form method="get" target="_blank" name="searchform" id="searchform" action="http://kb.mit.edu.ezproxyberklee.flo.org/confluence/display/home/Search+Results"> <input type="hidden" name="searchSpaces" value="ist,istcontrib,istdraft,mitcontrib,hd,handbook,glossary" /> <input type="hidden" name="resultPage" value="Search+Results"/> <input type="hidden" name="resultSpace" value="home"/> <input type="text" size="60" name="searchQuery" if="searchQuery" value="" /> <input type="submit" value="Search Knowledge Base Answers" /> </form>