We have upgraded our support system to serve you better.
For Support, please go to our Momentive Support Hub located here.

Skip to main content

Google search in eWeb

 
 

Google search in eWeb

Google has released a version of their Custom Search Engine that allows you to pay a nominal fee for basically removing the ads from search results. It's pretty straightforward to set this up and add the script code to a basic web page - in a matter of minutes you can have a Google-like search working on your website!

Because eWeb pages are being served up dynamically via the CMS, there are some issues with getting this Google code to work on an eWeb CMS page. The Google Custom Search Engine really needs it's "own" FORM tags in the webpage code in order to identify where the search is coming from - and the eWeb CMS (via DynamicPage.aspx or other "core" page functionality) is already "using" the FORM tag. So, the workaround that I developed involves creating a "middle" ASP page to send the search through.

Here's how I got this to work on my site. First of all, the CMS page in eWeb has this code in "Top" SITE Default HTML element (you don't have to do this site-wide if you don't want, but if you want to catch ALL your CMS pages, put this code at the SITE default level) - this code basically adds a Google search box to the top of an eWeb CMS page:

<TABLE cellSpacing=0 cellPadding=0 width=230 align=right border=0><TBODY><TR><TD align=right width=179><INPUT type=hidden value=00597481890xxxxxxxxxxxx:fcdevxxxxx name=cx><INPUT type=hidden value=FORID:9 name=cof><INPUT size=25 name=q></TD><TD vAlign=bottom width=51><INPUT onclick="this.document.forms[0].action='http://www.yourwebsite.com/searcheweb.asp'; this.document.forms[0].submit();" type=image src="http://www.acfe.com/images/find.gif" align=absMiddle value=Search border=0 name=sa></TD></TR></TBODY></TABLE>

You can see that this code makes a call to "searcheweb.asp". This is the "middle" layer I discussed. Instead of this search box submitting the search to Google, basically eWeb submits the search term to the searcheweb.asp page which then "forwards" the search (including the required FORM tags) to Google.

Here is the code for the searcheweb.asp page

<%@ Language=VBScript %><%Dim tempcxDim tempcofDim tempqtempcx = Request.Form&#40;"cx"&#41;tempcof = Request.Form&#40;"cof"&#41;tempq = Request.Form&#40;"q"&#41;%><HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"></HEAD><BODY><P><!-- Google CSE Search Box Begins  --><form id="searchbox_00597481890xxxxxxxxxxxx:fcdevxxxxx" action="http://www.yourwebsite.com/searchresults.asp"><input type="hidden" name="cx" value="<%=tempcx%>" /><input type="hidden" name="cof" value="<%=tempcof%>" /><input name="q" type="text" size="40" value="<%=tempq%>" /><input type="submit" name="sa" value="Search" /><img src="http://www.google.com/coop/images/google_custom_search_smnar.gif" alt="Google Custom Search" /></form><!-- Google CSE Search Box Ends --></P><script language="javascript">this.document.forms&#91;0&#93;.submit&#40;&#41;;</script></BODY></HTML>

Note that the "searchresults.asp" page would be just the search results page on your website with your website's look and feel. This page needs to include the Google code to display the results...something like:

<!-- Google Search Result Snippet Begins --><div id="results_00597481890xxxxxxxxxxxx:fcdevxxxxx"></div><script type="text/javascript">var googleSearchIframeName = "results_00597481890xxxxxxxxxxxx:fcdev7xxxxx";var googleSearchFormName = "searchbox_00597481890xxxxxxxxxxxx:fcdev7xxxxx";var googleSearchFrameWidth = 600;var googleSearchFrameborder = 0;var googleSearchDomain = "www.google.com";var googleSearchPath = "/cse";</script><script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script><!-- Google Search Result Snippet Ends -->

Finally - note that I replaced my site's Google-specific identification with the "x"'s in the above examples.

I'm sure there may be other ways to do this, but this has worked well for us! And now folks can do Google-like searches across our entire website (www.acfe.com). Hope this helps some folks out!

Jeff Miller IT Manager - ACFE jeff.miller@acfe.com

Was this article helpful?
0 out of 0 found this helpful