Tuesday, September 2, 2008

Search Blogger Profiles for people with similar (or different) movie tastes

Last week, we threw together a little web-based search form that allowed us to search for Blogger profiles by country. Although we could certainly take it a step or two further, I'd like to make a little detour this week to explore a different direction-- namely, movies.

Your Blogger profiles allows you to list your favorite movies. Much like the location field, any movie titles that you type in become hypertext links. If you click on one of those "Favorite Movie" title links, the Blogger profile search program displays other Blogger users who have entered the same movie title as one of their favorites. It's sort of cool, I guess--you can find people with similar cinematic tastes, subscribe to their blog, and then argue endlessly about whether Shane dies at the end or not.

But what happens if you want to find someone who liked a movie that you aren't willing to list in your favorites? Perhaps you fear to admit "Ernest Saves Christmas" is one of your favorite comedic movies, but secretly wish to find other people who recognize the hidden genius of Shakespearean actor, Jim Varney. Or maybe you just want to know if anyone out there would admit "Showgirls" was their favorite movie?

If so, then today is your lucky day, my friend. ;)

As always, let's start from something we know-- like the URL of a typical Blogger search with one of the movies from our own Blogger profiles:

http://www.blogger.com/profile-find.g?t=m&q=The+Princess+Bride

The basic URL (i.e. the http://www.blogger.com/profile-find.g? part) remains unchanged from our previous "search by country" example. The value of the first parameter after the question mark changed from an "l" (for location) to an "m" (for movie). But, the second parameter (that is, "q=") and the value for that second parameter ("The+Princess+Bride") are completely different. The "q" stands for query, if that will help you remember it-- and the text after the equal sign is obviously the title of a movie, but with plusses instead of spaces between words. It's a trick to keep the URL from having spaces in it, which could cause problems with links as well as passing the data to the search program.

Rather than build another web-based search form from scratch, let's try just modifying the form we created last time. Here it is:

<form action="http://www.blogger.com/profile-find.g" method="get">
<input name="t" value="l" type="hidden">
<select name="loc0" id="loc0" style="font-family: Verdana,sans-serif;">
<option value="_nil_">Select a country</option>
<option value="AF">Afghanistan</option>
. . . not all countries are listed, obviously . . .
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option></select>
<input value="Submit" type="submit">
</form>

I've italicized the lines that are specific to the country search, which we will remove. This leaves us with the following:

<form action="http://www.blogger.com/profile-find.g" method="get">
<input name="t" value="l" type="hidden">

. . . we've removed the drop down list, and will replace it with a text field . . .

<input value="Submit" type="submit">
</form>

That second line is a hidden field we use to pass the type of query (i.e. location, movie, etc.) to the Blogger Profile Search Program. It's currently set to a value of "l" (as in, location) which won't do us much good. To make it search for movies instead, we just change the value to "m" instead. That leaves us with:

<form action="http://www.blogger.com/profile-find.g" method="get">
<input name="t" value="m" type="hidden">

. . . we've removed the drop down list, and will replace it with a text field . . .

<input value="Submit" type="submit">
</form>

Almost done. The last thing we need to do is put in a text field so people can type in the name of any movie title. As always, I leave the specific text and styling decisions to your preferences:

<form action="http://www.blogger.com/profile-find.g" method="get">
<input name="t" value="m" type="hidden">
<p><input name="q" id="q" style="font-family:Verdana, sans-serif;" />
</p>
<input value="Submit" type="submit">
</form>

Go on, give it a test drive and see for yourself. I know, some of you might be wondering about how we're going to get the plus signs in between the words of movie titles. Is it a trick with Javascript? Actually, the good news is that the web browser takes care of that little detail in the background for us when the user hits the Submit button. (editorial note: I haven't tested this with every single browser out there in the wild, but it works with Firefox 2.0 on the Macintosh definitely, and I expect this trick will work with most modern browsers.)

Blogger Profiles Search: Movies!

Enter any movie title:



No comments: