Live Search module for Drupal 5

  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/kourge/ on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/kourge/ on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/kourge/ on line 345.

As Drupal is was approaching its 5.0 release, Jared of littlegreencube brought my attention to the lack of decent live search functionality for Drupal when he saw my article on live search in Drupal. The word "hack" can't aptly describe how much of a kludge my previous attempted approach to live search for Drupal 4.7 was.

Since Drupal 5.0 ships with the fabulous jQuery JavaScript library that provides good Ajax functionality, I took this as a personal challenge. Not having written a Drupal module or used jQuery in my projects (I'm a heavy Prototype user), I thought this would be fun. The best approach would be to write the whole thing as a module to allow portability.


Although there's already a Live Search module on, my main point is:

  • To specifically target Drupal 5.0
  • To utilize jQuery
  • To tap into the existing search.module API instead of reinventing the wheel
  • To provide portability and flexible settings

To separate live search into a module was apparently the right direction. Because of this, the live_search module depends on the search module.

The torment

After 4 days of hacking and reading the Drupal API reference feverishly, I'm finally done with the module in question. Sure, it took time, but a good read on Drupal's function hook mechanism helped a whole lot more. Drupal API reference is a very good resource for Drupal developers of any kind, and I can't imagine writing a module without it. Peeking other modules' source code also helps people to get a grasp of the whole idea.

Enought rambling

I present you the live_search module working live and well on the Live Search demo site I set up. It's a zip file for now. Get the zip.

Live Search is now an official contributed module on See the Live Search project page.

Not dogfooding?

Yes, I am dogfooding this now.

Caveat consumor

This module depends on search.module. Enable the Search module first and let it index your site if you haven't done so. Needless to say, this module only works on Drupal 5.0.

This has been tested on Drupal 5.0 and works on the following browsers that I have tested:

  • Firefox 2.0 (of course)
  • Opera 9
  • Internet Explorer 6 (surprised?)
  • Safari 2


This site is now upgraded to Drupal 5 and it's of course dogfooding my very own live search module. Everything looks nice and well.

Thanks alot! I'm going to

Thanks alot! I'm going to try this as soon as I get home!

I don't suppose there's any

I don't suppose there's any chance you're planning to update this for Drupal 6.x? I understand your site is clearly still using Drupal 5 because you make use of your own Live Search, and I've seen it at which looks amazing. His even detects Safari compared to other browsers and displays the search form differently. It's amazing.

I'd love to be able to do this with Drupal 6.x - any plans?