Page 1 of 1

Can Google Custom Search work in Able?(edit: YES)

Posted: Fri Aug 14, 2009 11:39 am
by William_firefold
We want to use google custom search on the site but I cant get it to work.
The plan is to have the custom search input box where the Able search is now, and have the results appear on a page made for googles output.
The results are pulled with a snippet of google JS, which uses a get variable to define the search. The problem I have found is that when you make the input form target a .aspx file(which itself brings in its content and layout from scriptlets) the get variable doesnt make it to the results code snippet.

I was trying to follow instructions from here http://dotnetslackers.com/articles/aspn ... earch.aspx but this is not the same complexity as Able.

Is there a way to set up this search the way we want to?

Re: Can Google Custom Search work in Able?

Posted: Mon Aug 17, 2009 7:23 am
by William_firefold
This seems like it should be possible, but I dont know what to do in Able.

Re: Can Google Custom Search work in Able?

Posted: Mon Aug 17, 2009 11:19 am
by jmestep
I'm not sure what problems you are running in to, but try putting it into a custom conlib and then putting that conlib on the page. Merchants have had to do that with email signup programs, contact forms since all the .net pages already have a form on them.

Re: Can Google Custom Search work in Able?

Posted: Tue Aug 18, 2009 5:21 am
by William_firefold
Our problem is that nothing happens when you search. The google page says that you can use an iframe on the target page to receive the search results. The search box does some unknown stuff using javascript and get variables, and ends up redirecting to the target page like so:

Code: Select all

http://www.firefold.com/googletest2.html?cx=014731849385091516742%3Ae-rar04i5je&cof=FORID%3A10%3BNB%3A1&ie=UTF-8&q=hdmi&sa=Search#906
This works for the simple html file here, but will not work when the iframe is placed in a scriptlet or conlib. here is the code for the result page:

Code: Select all

<html>
<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 600;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script></html>
Im not sure where to begin, but google says this is supposed to be simple. Does anyone know where im going wrong?

Re: Can Google Custom Search work in Able?

Posted: Tue Aug 18, 2009 5:58 am
by jmestep
This might help- I haven't read it, though.
http://www.eggheadcafe.com/community/as ... n-asp.aspx

Re: Can Google Custom Search work in Able?

Posted: Tue Aug 18, 2009 8:01 am
by William_firefold
Very helpful.
Google Custom search(no offense) is so much better than the stock Able search. No images, but at least it can find what you are looking for.
Will post my complete code for anyone who wants to implement.

Page File

Code: Select all

<%@ Page Language="C#" MasterPageFile="~/Layouts/Scriptlet.master" Inherits="CommerceBuilder.Web.UI.AbleCommercePage" %>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls.WebParts" TagPrefix="cb" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="PageContent">
<cb:ScriptletPart ID="Privacy" runat="server" Layout="Two Column" Header="Search Header" Sidebar="Short Sidebar" Content="gresult page" Footer="Footer With Google Analytics" AllowClose="False" AllowMinimize="false" />
</asp:Content>
Scriptlet:

Code: Select all

[[ConLib:custom/GCSResult ]]
GCSResult.ascx:

Code: Select all

<div style="width:792px;padding:0 0 0 5px;background:#fff;overflow:hidden;">
<div id="cse-search-results" style=""></div></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
Then just modify your search bar, SimpleSearch.ascx.cs:

Code: Select all

using System;
using CommerceBuilder.Utility;
public partial class ConLib_SimpleSearch : System.Web.UI.UserControl
{
    protected void SearchButton_Click(object sender, EventArgs e)
    {	
    //  string safeSearchPhrase = StringHelper.StripHtml(SearchPhrase.Text).Trim();
    //  if (!string.IsNullOrEmpty(safeSearchPhrase))
    //  Response.Redirect("~/Search.aspx?k=" + Server.UrlEncode(safeSearchPhrase));
    //  Response.Redirect("~/Search.aspx");
	string s1=SearchPhrase.Text;
   string s2=s1.Replace(' ','+').ToString();
   string s3="http://www.FireFold.com/CustomSearch.aspx?cx=014731849xxxx91516742:e-rarxxi5je&cof=FORID:10;NB:1&ie=UTF-8&q="+s2+"";
	Response.Redirect(s3);
    }
}
Get the iframe code from google, and fill in your GET variables in the URL from the code that google gives you.

Re: Can Google Custom Search work in Able?

Posted: Tue Aug 18, 2009 9:17 am
by Logan Rhodehamel
William_firefold wrote:Google Custom search(no offense) is so much better than the stock Able search.
I won't take it personally that Google handles search better than we do. :) We have improved the search capability with addition of Full Text Search in 7.0.3, but a Google spider is going to see the site more completely. This is a great little adjustment.