Took the code off the following link after a response on www.dotnetnuke.com forums:
http://weaselfire.wordpress.com/2009/06/17/google-custom-search-for-dotnetnuke/#comment-7
I got my Google API, added a TEXT/HTML module and then cut and pasted with the appropriate website URL edits only to get the folllowing error:
Line: 552
Char: 1
Error: ‘google.search.SearchControl’ is null or not an object
Code:0
URL:
I am using IE7 and added the new TEXT/HTML module to the existing DNN search results page. The search box is rendered but I get the yellow error box in the bottom left corner of IE. When I type a search string, the keyboard does not respond to the RETURN key to start the search. Any ideas...I like the idea of the code and the ability to search documents in the portal... I also tried it on a dedicated DNN webpage with the same error....here is the page.... :
http://www.insidertech.co.uk/GoogleSearch/tabid/199/Default.aspx
And here is my amended code I am using :
<script src="http://www.google.com/jsapi?
key=ABQIAAAALgmUPRveB57J3cnHdwLwMhTLsVmvth3u1C1qO3eoCMoX_mXkHhQuG7ZvjZm9rAR-jg3RXjAMIl3e1g"
type="text/javascript"></script><script language="Javascript" type="text/javascript">
// Script based on a blog post at:
// http://www.eguanasolutions.com/DNN_Blog/EntryID/7.aspx
<!-- google.load('search', '1.0');
function checkKeypress(e)
{
var kC = (window.event) ? event.keyCode : e.keyCode;
var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE;
if (kC == Esc) { event.keyCode=13; return; }
if (kC == 13) return false;
return kC;
}
function OnLoad()
{
var searchControl = new google.search.SearchControl();
var drawOptions = new google.search.DrawOptions();
drawOptions.setInput(document.getElementById("gss_input"));
var options = new google.search.SearcherOptions();
options.setExpandMode
(google.search.SearchControl.EXPAND_MODE_OPEN);
options.setRoot(document.getElementById("gcsResults"));
searchControl.setResultSetSize
(google.search.Search.SMALL_RESULTSET);
// Set up a site search - searches the web site pages
var siteSearch = new google.search.WebSearch();
// Replace the site root with your own site URL
siteSearch.setSiteRestriction("http://www.insidertech.co.uk/");
// We're only including "aspx" pages from our site.
// We're specifically excluding "LinkClick" page links
// (links with "fileticket")
siteSearch.setQueryAddition("+filetype:aspx -fileticket");
siteSearch.setUserDefinedLabel("Web Pages: ");
searchControl.addSearcher(siteSearch, options);
// Configure a search of physical files available
// for download
var fileSearch = new google.search.WebSearch();
// Replace with your own URL, portal and folder
// with the files to be searched
fileSearch.setSiteRestriction
("http://www.insidertech.co.uk/Portals/0");
fileSearch.setQueryAddition("-filetype:aspx");
fileSearch.setUserDefinedLabel("Files: ");
searchControl.addSearcher(fileSearch, options);
searchControl.draw(null, drawOptions);
}
google.setOnLoadCallback(OnLoad, true);
-->
</script>
<div>
<p>To search all of www.insidertech.co.uk for words, phrases and documents, enter a search term below:</p>
<input onkeypress="return checkKeypress(event)" id="gss_input" onfocus="if (this.value==this.defaultValue)
this.value='';" size="80" value="Search Now" type="text" /></div>
<div id="branding"> </div>
<div id="gcsResults"> </div>