Bugzilla tweak: search all

August 23, 2007 at 11:03 am | Posted in Bugzilla, code, hack, technology, tweak | Leave a comment

I’ve just recently implemented a Bugzilla installation for the regional drug information center (behind an intranet so I can’t link you to it – yet). Anyhow, I had some difficulties with making it so the “quicksearch” in the header, footer, and main page searched everything instead of just open “bugs” or as I refer to them now, “requests”. Since I couldn’t find anything when I Googled for help, I thought I would post my fix just in case someone else might be trying to do the same thing.

Some background here: Bugzilla lets you search all bugs by inserting ALL in front of the search teams. But the pharmacist and I both thought that that would be an obstacle for our average end user, other pharmacists and physicians. So what is outlined below is a way to accomplish this search without losing the ability to “jump” to a bug by entering the bug ID.

There are two files that you’ll need to edit. I didn’t find out until after I put the tweak/hack in that any changes should be put in the custom directory, so remember that good practice would have you do just that. Anyways, the two files you are looking for are in the /template/en/default directory of your Bugzilla installation. Follow the steps below (I’m using MacOSX terminal to ssh to a SuSE Linux box, but I think the directory structure should be the same if not very similar across operating systems) to enable “search all” bugs from the header, footer, and main page:

  1. Navigate to your Bugzilla installation
  2. Change directory to template/
  3. Change directory to en/
  4. Change directory to default/
  5. INSERT good practice here: instead of editing as instructed in step 6, you should copy that file to the custom/ directory and then edit it.
  6. Edit index.html.tmpl (I use VIM, but use the editor of your choice)
  7. Almost at the very bottom of the file, you will find a line that begins with:
    • <form id="f" name="f" action="buglist.cgi" ... >
  8. Replace the onsubmit action with the following:
    • onsubmit="if (this.quicksearch.value == ''){ alert('Please enter one or more search terms first.');return false; } if (isNaN(this.quicksearch.value)) {this.quicksearch.value = 'ALL ' + this.quicksearch.value; return true;} return true;"
  9. Save index.html.tmpl
  10. Change directory to global/
  11. INSERT good practice here: instead of editing as instructed in step 12, you should copy that file to the custom/global/ directory and then edit it.
  12. Edit common-links.html.tmpl
  13. You’re going to insert the same onsubmit code as before, but this time the place you’re going to do it is at the very top of the file underneath the line that reads:
    • <form action="buglist.cgi" method="get"

And that’s it! Now you’re users should be able to enter search terms and search all bugs without having to type in the word ALL before their search terms (the code snippet will add the word ALL automatically). Secondly, if the user knows their bug # and wants to use the search box to “jump” to that bug, the code snippet checks to see if it is a number, omitting the word ALL if it is (that is the isNaN statement).

Let me know if this works for you…Worked great for me!


Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: