SharePoint 2020

The Vision for a Future of Clarity

Google Search Appliance Web-Part for SharePoint Results Page

I found this code a while ago and used it in our SharePoint 2007 Intranet site.

The code worked the same when our sites migrated to SharePoint 2010, so I’d thought I’d share it here.

The search displays both results at the same time on the results page.

I don’t know where the code originated from, I’ve searched everywhere but can’t find the original Blog Post.

Once you modify the code with your own Google Appliance settings, just replace those settings in the code below.

You might have to find your Google Search Appliance settings by viewing the source-code from the Google search results page.

Once edited, just save the code to a text file, upload it to a Document library, copy the link and paste into a Content Edit Web Part on the SharePoint Search Results Page.


<div id="googleSearchResults">loading...</div>
<script type="text/javascript">
var gsaHost = 'http://googlesearch.intranet.au/search?output=xml_no_dtd';
var gsaCollection = 'default_collection';
var gsaClient = 'Intranet_frontend';
var gsaStylesheet = 'Intranet_frontend';
var gsaAccess ='p';

function getParameter ( queryString, parameterName )
{
// Add "=" to the parameter name (i.e. parameterName=value)
var parameterName = parameterName + "=";
if ( queryString.length > 0 )
{
// Find the beginning of the string
begin = queryString.indexOf ( parameterName );
// If the parameter name is not found, skip it, otherwise return the value
if ( begin != -1 )
{
// Add the length (integer) to the beginning
begin += parameterName.length;
// Multiple parameters are separated by the "&" sign
end = queryString.indexOf ( "&" , begin );
if ( end == -1 )
{
end = queryString.length;
}      // Return the string
return unescape ( queryString.substring ( begin, end ) );
}   // Return "null" if no parameter has been found   return "null";
}
}
function search()
{
var results = document.getElementById("googleSearchResults");
document
var iframeHTML='\<iframe id="RSIFrame" allowtransparency="true" scrolling="no" frameborder="0" style="';
iframeHTML+='border=0px;';
if (navigator.appName == 'Netscape')
{
iframeHTML+='width:98%;';
}
else
{
iframeHTML+='width:100%;';
}
var query = getParameter(window.top.location.search.substring(1),"k");
if (query == null)
{
query = '';
}

iframeHTML+='height:1500px;';
iframeHTML+='background:transparent;"';
iframeHTML+=' src="' + gsaHost + '?site=' + gsaCollection + '&client=' + gsaClient + '&access=' + gsaAccess + '&proxystylesheet=' + gsaStylesheet + '&entqr=0&ud=1&sort=date%3AD%3AL%3Ad1&output=xml_no_dtd&oe=UTF-8&ie=UTF-8&filter=0&q=' + query  + '"';
iframeHTML+='><\/iframe>';
results.innerHTML = iframeHTML;
}
search();
</script>

Advertisements

May 6, 2012 - Posted by | SharePoint 2007, SharePoint 2010 | , ,

No comments yet.

Post a Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: