Movable Type Livesearch

Sorry for the long absence, but I’ve been busy working and packing for my impending move (more about that in the next post!). However, I did manage to find time to fix something that’s been nagging me about the blog for a while.

livesearch

Check out the new livesearch function over on the right!

Ever since the last major redesign, I’ve really wanted to add a “livesearch” function to the site. Up until now, all site searching was handled through Google via the “site search” box over on the right. It works okay, but the Google search page is pretty ugly in addition to serving up ads and some not-so relevant results at times.

What I wanted to do was something akin to what Dunstan’s amazing 1976design blog – a live search that returns dynamic results that change according to what you type into the box. If you’ve ever used the iTunes search function, then you’ll know right away what I’m talking about.

A quick glance around the internet reveals that a few people have implemented a live search for movable type, and a couple have even gone as far as to release some scripts into the public domain. While I was tempted to copy and modify some of those scripts, as the saying goes, nothing beats doing it yourself. Thus, this past rainy Saturday, rather than spending hours trying to figure out how I was going to fit all my clothes into such a small number of boxes, I finally sat down, stopped procrastinating, and wrote a live search script that would do exactly what I wanted.

spring stylesheet

Did you try out the new spring stylesheet yet?

You can see it running over on the sidebar on the right of the main page. Scroll down about 1/3 of the page, and just where you see the “Bamboo Widgets”, click on the box titled “Blog Live Search”. Start typing your query into the box and voila! you should see your search results appear as if by magic (AJAX magic, baby) right underneath. Cool, huh?! The more terms you type, the more refined the results will get.

There are still a few quirks to work out, but it’s pretty much the effect I was after. Please give it a try and let me know what you think about it – do you like it, hate it, does it not work for you/your browser, etc?

And that’s it! Right now it’s a beautifully cool summer evening in the hood – sitting at the table by the open window, crisp breeze blowing through the house, AfterHoursDjs.org playing some absolutely kicking jams, just about everything crossed off my “To Do” list, and a relatively easy day at the office waiting for me tomorrow to top it all off.

Life isn’t bad at the moment.

Notes on the Livesearch Function
  • Each term you type is automatically included by default
  • Use - in front of a word to exclude all results that contain that term.
  • Use * attached to a word to get wildcard matches. So “runn*” matches running, running and runneth, for example.
  • The more you type, the more the search results are refined. Keep typing to narrow down your choices!
  • To avoid overflow, the script only returns the first 10 results for a query. If you want to see all the results, either refine your query by adding more search terms, or else use the Site Search box.
  • The minimum length for a search term is four (4) letters.
  • There’s still a few bugs in the script – it returns broken links for moblog entries, for example. I’ll fix this later.
  • This script only searches blog entries. If you want to search the entire site (including galleries, etc.) use the Site Search.
  • Right now, searching in Japanese is not supported (more due to how Movable Type stores non-western characters than anything). I’m going to fix this soon.
  • For now, you can only access the livesearch on the main blog index page.

If you notice any errors, or if you have any feedback, please let me know below!!

Now listening to: “AfterHoursDjs.org” – They’re just tearing shit up right now!!

5 Reactions

  1. Shay

    That’s a great little widget. Awesome job and thanks for stoppin’ by :)