As part of the blog transition I took a spin at creating a new tool that would create a WordPress search bookmarklet, more or less a quick re-do of the one I originally created for MovableType.

It is even easier to construct for WordPress, as all you need to know is the base URL for the WP blog- the WordPress search URL is very simple, merely the URL plus a value to pass for the key word search:

making it really easy to create permanent bookmarks for blog searches, e.g., my spam roach collection:

http://cogdogblog.com/index.php?s=spam+roach.

Hmmm, this is a sneaky way to make new pseudo categories.

Anyhow, another cheap WP hack is the new Make a WordPress Search Bookmarklet– it allows you to create a browser bar tool that can either do a search of a particular WP blog using any text highlighted in a page, or it will pop up an input box for entering the search terms.

This way you can search any WordPress Blog w/o having to go to the blog itself and use the search form.

This would have been easier, except I found out testing that recent versions of Safari and Firefox treat the JavaScript getSelection() function differently, whereas before it was always a string, now it is an object, but apparently methods of the result behave differently. The fix, with help from Joe Maller’s blog, is to contcatenate the results with an empty string, thus you end of with a string to test with again.

So any old bookamrket that relied on:

is broken as on some browsers the results when there is no selection range from “undefined” to “” to ???. The easy fix was to adjust the code to force conversion to a string:

so the if() statement is forced to be testing a tring.

The post "WordPress Search Bookmarklet" was originally zapped with 10,000 volts and declared "It's ALIVE" by Dr. Frankenstein at CogDogBlog (http://cogdogblog.com/2005/05/wordpress-search-bookmarklet/) on May 4, 2005.

Comments are closed.