The purpose of this exercise is to demonstrate how URL query strings can be used to create search widgets that can be embedded in websites.
The basic premise of this exercise is that you can create customized searches by manipulating the URL of the hyperlink you are sending your viewer to. Our project will be to create a search plug-in for our users so that they can easily find Creative Commons images on Flickr.
First, let's look at what happens with the URL when you conduct a search. Using the concepts we will discover in this section, we will then create a custom search box in Part B that will allow us to direct our users to a list of results on Flickr based on the terms they entered in a search box on our site.
The basic pieces are simple enough, and once we put them all together we will have created a nice little search plug-in.
If you do a search in Flickr for 'Schipperke puppy photos' and then filter your results to
Creative Commons images only, you will get this URL:
Can you spot the following query string in the full URL above?
This means that we can substitute other terms and insert them into the URL to create an address that will take us to a search for those terms.
To search for 'baby pandas' we can use the query string:
And plug that into the URL above in place of the 'puppies' query string like so:
If we want to create a similar link to look up items in our library catalog, all we need to do
is figure out where the query string comes into play by doing a search in the catalog.
In the HSU Library
Articles+ database, a search for 'baby pandas' would give us this URL:
+symbol instead of the
%20encoding that was used in Flickr. These two can usually be used interchangably and the browser will figure out how to get to the URL, but it is still something to pay attention to.]
This means that we can throw any terms at the end of this URL- the only trick is getting the terms we want and generating the custom URL. There are a few ways that we could use this on an actual site:
Here is an example of the third option, using the title of this exercise as the placeholder text. Test it out for yourself:
Before moving on to Part B, take some time to think about the various ways we can use these query strings. Try out your own searches and see if you can figure out how to manipulate the URL query strings to make your own searches.