Creating Search Provider for IE7
Creating Search Provider is very simple. Just follow these steps and you are done.
-
Create Search pages on your website.
-
Make sure you can get search parameters via query string
-
Create an XML file and upload to your server
-
Add special link tag inside your header tag.
-
(Optional) provider user the ability to click and install your provider
Let's go through these steps, step by step.
Create Search pages on your website
Well, you will have to do it yourself. Indeed, based on your website contents, you will have to
build a search page which may take search keywords in query string and display results. It really doesn't matter
how do you display search results or you dont display at all. Or you display any custom page. Its all upto you what kind
of contents you are going to display on the search page.
Create an XML file and upload to your server
Ok, this is the second important thing for IE7 to know that you implement search provider. the XML is very simple. Just take a look at this.
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Sameers theAngrycodeR</ShortName>
<Description>Sameers Sample Search provider</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template="http://www.theangrycoder.com/Search.aspx?q={searchTerms}"/>
</OpenSearchDescription>
Ok, its very clear, you will have to modify the above XML snippet to match your needs. Replace the ShortName with your desired name which will appear
on search box or when you are installing the provider. Description, for sure is the detail about the search type. Input Encoding is the text encoding.
And finally, replace www.theangrycoder.com/Search.aspx?q= with your own site url like www.mysite.com/SearchPage.aspx?q=. Note that it is really not
necessary to use query string variable q, you can use any, for example, search as the querystring variable.
Once you have created this XML file, save that it to any name, for example, Provider.xml. Upload to your website. Now the final thing we need to do is to let the
IE7 know that you have search provider on your site. Lets do it.
Add special link tag inside your header tag
As the XML file itself was easy, so this link tag is more than that.
<link title="Sameers Sample Search" rel="search"
type="application/opensearchdescription+xml"
href="http://www.theangrycoder.com/Provider.xml" />
All you have to do is to replace the www.theangrycoder.com/Provider.xml with the path of your XML you uploaded in above step. You should also change the title to something
describing your site search. Once you are done adding this link tag, upload page on your server and then navigate to the page which contains this link tag. You will see a light orange
color of search provider drop down arrow (which means, IE7 search provider is available on this site). Drop down that and you will see your search provider name. Click on that, add some
search string and press enter. WOW! browser navigated to your search page.
(Optional) provider user the ability to click and install your provider
Well, this means, you provide an option to visitors somehwere on your page to add your search provider in their IE7. Lets See how.
<a href="#" onclick="javascript:window.external.AddSearchProvider('http://www.theangrycoder.com/Provider.xml');">
Sample Search Provider<a>
Thats all! Now you know everything to play with search providers for IE7. For more referece,
you can consult following links
Adding Search Providers
OpenSearch Description