But how do I connect this to the search box on my home page (not just
the search box on the search results page?)
The last paragraph of this section of the documentation says the
search box can be "decoupled":
http://code.google.com/apis/ajaxsearch/documentation/#SearchControlModes
and gives this example:
http://www.google.com/uds/samples/apidocs/searchformroot.html
But the box is still on the same page in that example. Possible to
draw from a search box on the home page instead?
Thank you,
Nathan Bierma
Grand Rapids, MI, USA
www.nbierma.com
Can anyone point me in the right direction please?
Thanks.
Nathan
I created a small sample page which I think might help. The first page
has a form which will send the user to a results page with q=the
user's query in the URL. The results page extracts the user's query
from the URL and feeds it into the custom search execute command. Hope
this helps, please let me know if any of this is confusing as I think
this might become a helpful example.
http://ajax-apis.appspot.com/html/two_page_search.html
Happy coding,
Jeff
On Mar 1, 6:07 am, nbierma <nbie...@gmail.com> wrote:
> Here's an expanded version of my question with some sample code:http://bit.ly/gglcseq1(see 4th reply). I think the key is getting the
In the Custom Search forum, some Custom Search Engine users have
requested such functionality since last year. So I had considered
posting essentially the same kind of solution that you've suggested
today. But I hesitated, because I wasn't quite certain if such an
implementation was permitted.
If such an implementation is permissible for use with CSEs, then I
wonder why such requested functionality has never before been
officially provided or documented for use with the AJAX Search API-
based Custom Search Element.
For years, Custom Search Engines have provided an option to host CSE
results within an Iframe on a separate results-page. That
implementation (which has some IMO significant known issues and
limitations, discussed many times in the current and archived CSE
forums) doesn't use the AJAX Search API.
Given the longtime existence of that option, and the desire for a
better alternative, I was disappointed to see that the AJAX Search API-
based Custom Search Element (using the Custom Search Control),
introduced last year, only supports (in its official implementations
and documentation) a single page, not a separate results-page.
So for the past few months I have been wondering why the CSE folks
chose not to provide a separate results-page option for the Custom
Search Element, using an implementation similar to what you have shown
in your example.
-- omr
I'd like the results to appear just the way they do at this sample
page from the AJAX API, with tabbed alternate searches on the right
side:
http://www.google.com/uds/samples/cse/index.html
I tried getting your example to do this but couldn't get it to work:
// draw the left and right controls
// the right control is drawn in tabbed mode
var drawOptions = new google.search.DrawOptions();
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
this.leftControl.draw(leftScDiv);
this.rightControl.draw(rightScDiv, drawOptions);
Can someone set me straight? Much appreciated,
Nathan
Good questions. I think one of the challenges with a two page approach
like this is that it requires more work on the web developer's part
than an all-in-one-page-ajax solution. You would need to wire up page
1 to send the user to page 2. One of the things that I think our users
like about the custom search control is that it provides the results
to the end user without taking them off of the current page. For the
people who do want to user to go to another page, they are free to
build their own solutions as I've done.
Happy coding,
Jeff
Thanks again for your helpful example.
As for your last post, I've found the code for using CSE on two pages
via an iframe very simple and straightforward: just a few lines of <
form > for our home page and a simple < iframe > on our results page,
so I don't think it makes it more complicated for web developers. And
for the user I think it's more intuitive to enter a search on a home
page and then land on a results page, the way they/we do on Google (or
Google Toolbar, via any page on the Web). Before you gave your
example, to use some cool Google AJAX API it would have to be on a
Search page that would just be linked from the home page, so a user
would have to click "Search" and then search, rather than just
entering a search on the home page, which is less seamless. So I do
think hooking up some of those AJAX search features with a two-page
option is very useful.
Speaking of which: As I posted above, I can't get your example to draw
tabbed results. Is there an easy way to do that?
Thanks,
Nathan
Great example! That's just what I was looking for. However, my
implementation (and your example, for that matter) does not work in
Internet Explorer. Now, I wish everyone in the world used FFox or
Chrome, but the fact is that there are still a bunch of people surfing
in IE.
Would you provide some advice on getting this operational in IE?
Thanks,
Tim
On Mar 1, 2:59 pm, "Jeff S (Google)" <j...@google.com> wrote:
> Hi Nathan,
>
> I created a small sample page which I think might help. The first page
> has a form which will send the user to a results page with q=the
> user's query in the URL. The results page extracts the user's query
> from the URL and feeds it into the custom search execute command. Hope
> this helps, please let me know if any of this is confusing as I think
> this might become a helpful example.
>
> http://ajax-apis.appspot.com/html/two_page_search.html
>
> Happy coding,
>
> Jeff
>
> On Mar 1, 6:07 am, nbierma <nbie...@gmail.com> wrote:
>
> > Here's an expanded version of my question with some sample code:http://bit.ly/gglcseq1(see4th reply). I think the key is getting the
But it doesn't work in IE 7 (Jeff's example doesn't work in IE7
either).
Does anybody have any ideas why that might be the case?
On Mar 1, 2:59 pm, "Jeff S (Google)" <j...@google.com> wrote:
> Hi Nathan,
>
> I created a small sample page which I think might help. The first page
> has a form which will send the user to a results page with q=the
> user's query in the URL. The results page extracts the user's query
> from the URL and feeds it into the custom search execute command. Hope
> this helps, please let me know if any of this is confusing as I think
> this might become a helpful example.
>
> http://ajax-apis.appspot.com/html/two_page_search.html
>
> Happy coding,
>
> Jeff
>
> On Mar 1, 6:07 am, nbierma <nbie...@gmail.com> wrote:
>
> > Here's an expanded version of my question with some sample code:http://bit.ly/gglcseq1(see4th reply). I think the key is getting the
if (parts[i][0] == 'q') {
to this:
if (parts[i].substr(0,1) == 'q') {
-- omr
http://nathanbweb.host22.com/try/search/search-example.html?q=sample
separate search box:
http://nathanbweb.host22.com/try/search/search-box.html
here's the pertinent code:
http://pastebin.com/D44WYzTn
and here's how I used it (with various CSE's) at my organization's
website:
http://www.calvin.edu/worship/search/results.html?q=lent
search box on our home page:
www.calvin.edu/worship
pertinent code:
http://pastebin.com/7iyVRMGY
Thanks to everyone for your help. Thanks, too, to omr for the IE fix
-- I hadn't tested for IE yet and it was a relief to see there was a
solution!
Nathan
Happy coding,
Jeff
The two-page example code fails for queries containing extended
characters.
(Thanks to "TerryE" for reporting this in the Custom Search forum.)
Jeff, these changes should fix the problem:
Please specify UTF-8 encoding on the search and results pages:
<meta http-equiv="content-type"
content="text/html; charset=utf-8">
Also, in the getQuery function on the results page, please use
decodeURIComponent() instead of unescape().
return decodeURIComponent(
parts[i].split('=')[1].replace(/\+/g, ' '));
.
Here is the original report by TerryE:
http://www.google.com/support/forum/p/customsearch/thread?tid=31aa13cb3e256b3d
-- omr
-- omr
It seems to me that the fix mentioned above is necessary in order to
execute searches containing extended characters (i.e., for languages
other than English). I wonder if you might want to update the example
on the blog to implement this fix?
-- omr
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" language="Javascript" src="/js/googlesearch.js"></script>