Share via


OpenSearch provider for MOSS search

It's nice to have that handy-dandy search bar in the upper right corner of your Internet Explorer browser, but how do you get that to show up with custom searches for MOSS?

Well, you'll need to build a custom opensearch provider for your MOSS site. For this instance, I will demonstrate a simple provider that you will add to your page layouts to direct searches to your main search.

First, we must make the OpenSearch XML. If you want a quick cheat, you can go here to use the IE search providers add-in. So, you'll need to create a file for each search provider you want to add to your page (i.e. All Sites, People, Intranet, Extranet, etc.).

IntranetSearch.xml

<?xml version="1.0" encoding="UTF-8" ?> <OpenSearchDescription xmlns="https://a9.com/-/spec/opensearch/1.1">    <ShortName>This text appears in the IE dropdown</ShortName>    <Description>This is the description</Description>    <InputEncoding>UTF-8</InputEncoding>    <Url type="text/html" template="https://search/searchcenter/pages/results.aspx?k={searchTerms}" /> </OpenSearchDescription>

Next, you'll have to add this to a common location that you will reference with the search provider.

  1. Open SharePoint designer.
  2. Create a folder called IESearchProviders (the name is unimportant).
  3. Copy all your OpenSearchProviders in the folder.

Finally, you'll need to go to your page layout. If you're like everyone else who customizes SharePoint, then you have a custom master page as well as custom page layouts. In any page layout (*.aspx) or master page (*.master) add the following link tag to the PlaceHolderAdditionalPageHead content placeholder:

<link title="This appears in IE dropdown as a new search type"       type="application/opensearchdescription+xml"       rel="search"       href="/SearchCenter/IESearchProviders/IntranetSearch.xml" />

Another scenario is to build an HttpHandler for the OpenSearch provider. This would allow you to programmatically modify the search results. Maybe you want to put the <link> tag on your master page so it appears on all sites, but you want the user to be able to define a search at the simplest of levels (as low as a document library).

Update:

I seemed to have forgotten to mention how to add a button to the page to provide the user an easier way of knowing that the search provider exists

window.external.AddSearchProvider(https://search/SearchCenter/IESearchProviders/IntranetSearch.xml)

Comments