January

03

by Kaj Kandler

I recently decided to replace the lucene based search engine on Plan-B for OpenOffice.org with a Google Custom Search engine. At first glance this seems to be an easy task. Remove the old code and replace it with some Google Java scripts. However this is not how it turned out to be.
I targeted a layout, where the search box is part of the general navigation menu bar and results appear on their own page. However the HTML/CSS code generated by Google is rather inflexible. The two page template came the closest as it generates two separate code snippets, one for the search box and button and one for the search results.
So I had to add some CSS to make the divs and its generated child elements inline elements

div#cse-search-form {
display: inline-block;
zoom: 1;
...
}
div#cse-search-form * {
display: inline;
...
}

Another inconvenience is that the JavaScript includes an absolute URL for the results page. But it also works when I omit the protocol and hostname part

options.enableSearchboxOnly("/search/index");

Leave a Reply

You must be logged in to post a comment.