Andrej Tozon's blog

In the Attic

NAVIGATION - SEARCH

Search this blog

In one of my previous posts I wrote about OpenSearch and adding OpenSearch providers to your browser's Search toolbar. If you're using Community Server for your blog/forums engine, you can easily enable your visitors to take advantage of such providers to search through your site.

For example, when you visit my blog, you'll see a dropdown button next to browser's search icon turn orange. This means that browser [should be IE7, Firefox 2 or some other browser, supporting search providers] found a search provider on this page and has made it ready for you to use. Just enter the desired keywords, open the dropdown and select Andrej Tozon's Blog Search - your browser will take you to blog's search results page. To make this provider stay in your browser's search providers dropdown for future use, select Add Search Providers | Andrej Tozon's Blog Search from the same menu.

To implement this kind of search on your own site, create an OpenSearch description file, called opensearch-description.xml. This file describes your provider and should look something like:

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
  <ShortName>My Search</ShortName>
  <Description>Search my site</Description>
  <LongName>My Search Provider</LongName>
  <Tags>Blog, Community</Tags>
  <Url type="text/html" template="http://www.mysite.com/blogs/user/search.aspx?q={searchTerms}&o=Relevance" />
</OpenSearchDescription>

[Note: the above bold text represents a link, used by Community Server to display the search results page. If you're using a different kind of site engine and it supports searching, replace that link with the one your engine uses.]

Put the OpenSearch description file, you've just created, somewhere on your site, then edit one of your web pages, where you want your provider to be discovered [best place for this is usually the master template file]. Here's the contents that should go into this file's <head> section:

<link title="My Search" type="application/opensearchdescription+xml" rel="search" href="http://www.mysite.com/blogs/user/opensearch-description.xml" mce_href="http://www.mysite.com/blogs/user/opensearch-description.xml" lang="en" xml:lang="en" />

Make sure the link in the href attribute points to a valid OpenSearch description file you've created in previous step.

That's it, you're done. Navigate to your site with your browser and watch that icon go orange...

On a side note: I've also searchbox enabled our Developer users group portal [SLODUG/CodeZone-SI]; if you read Slovenian language, you're kindly invited to search through our posts...