GX WebManager comes with a very well equipped search engine based on Apache Lucene. But suppose you don’t have the time or resources to setup and tune a search engine and just want a plain out the box popular search engine? Google Custom Search might be a nice alternative for you. Occasionally we get this question from our customers and I will show you that implementing this is really easy and straightforward.
To create a Google Custom Search Engine - or CSE as I will call it from now on – go to
http://www.google.com/coop/cse/
You need a Google or Gmail account to create a CSE.
<%@ page language="java" session="false" buffer="none" %>
<%@ taglib uri="http://www.gx.nl/taglib/wm" prefix="wm"%>
<form action="${presentationcontext.page.link.url}" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="014765577166074708146:t_bphqhesla" />
<input type="hidden" name="cof" value="FORID:11" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="Search" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
<div style="overflow: auto">
<div id="cse-search-results"></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 450;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
</div>
The only thing that has to be changed in this JSPf is the CX value in the same hidden form field. Replace it by the value you copied from Google. Create an XML descriptor file for the JSPf and give it the same scope as the GX WebManager Search Element
<presentation> <name>GXlabs Google Custom Search element</name> <display-name>GXlabs Google Custom Search element</display-name> <scope>SearchElement</scope> </presentation>
From here on its time to play around with your CSE and JSPs. Some ideas:
http://www.hetnet.nl This is a combination between web search handled by Google and local site search handled by the GX WebManager search engine.
This simple presentation WCB could be replace by a special Google Custom Element WCB where you can enter the CX id manually and add more customization parameters.
You can dump your creations in the comments!
Martin van Mierloo is Product Manager and has many years of experience with GX WebManager. Martin writes about the GX WebManager roadmap, new product features and WCMS related topics..
Read all Martins blog entries
Other blog entries: