Is there an interest for a patch that allows one to use the 'Custom Search Element' Instead of the iframe? This would allow for a greater level of customization.

Essentially the idea is to add an API_Key field in the advance admin settings section. If a key is provided then other conditional fields appear for a greater level of customization.

Depending on whether or not $api_key is present, google_cse_results.tpl.php would either render the iframe version as usual, or render the Custom Search Element Version. We would loop through the advance settings options to see how to customize the Custom Search Element.

If there is enough of an interest for this feature I am willing to provide a general patch since I am already doing this because I need the ability to customize the default 'no results' statement (which can only be done via the Custom Search Element).

Comments

Donngal’s picture

That would be really great!

CodeBru’s picture

I second that!

gooddesignusa’s picture

It seems the iframe way has issues with chrome and some other browsers. The iframe height is way too big which results in a big gap under your search results. I've never messed with google custom search until today. So this is all new to me. After doing some googling I found out "Integrating Google Custom Search engine using Iframe hosting option is deprecated and no more supported." via: http://www.google.com/support/customsearch/bin/answer.py?hl=en&answer=70381

I was messing around with the layouts (http://googlecustomsearch.blogspot.com/2011/06/more-layout-options.html) today and copying the code google provided to test in a normal html file. That worked fine without any iframes which of course didn't have the issue. I was thinking of just adding google custom search manually to my theme but would like it if this module could do it :)

userok’s picture

subscribe

bryancasler’s picture

subscribe

gooddesignusa’s picture

StatusFileSize
new2.15 KB

I made a quick patch so that this can be used instead of the iframe method.

gooddesignusa’s picture

StatusFileSize
new2.17 KB

The patch I posted yesterday has a bug when searching from a 'search results block'. I made a new patch that can be patched on top of a clean copy. Does not require the first patch.

gooddesignusa’s picture

StatusFileSize
new2.17 KB

The patch I posted yesterday has a bug when searching from a 'search results block'. I made a new patch that can be patched on top of a clean copy. Does not require the first patch.

userok’s picture

you forgot to include a complete php opening tag:

change:
+ var customSearchControl = new google.search.CustomSearchControl('<? echo variable_get('google_cse_cx', ''); ?>');

to:
+ var customSearchControl = new google.search.CustomSearchControl('<?php echo variable_get('google_cse_cx', ''); ?>');

gooddesignusa’s picture

StatusFileSize
new2.17 KB

Sorry about that. Attached is a patch with that fixed.
I've been using this on a live site and it seems to be working fine.

nicolamj’s picture

This works for me. Would be nice if this could be committed because it looks like Google has phased out frame-based display now.

omnia.ibrahim’s picture

So the current module stopped working now, it was working with me till yesterday and stopped working today, is that due to the module uses frames?

gooddesignusa’s picture

@omnia.ibrahim
I did some quick google searching and it seems like they are starting to shut off the iframe method. Post just yesterday on their blog

"In August we transitioned all Google-hosted Custom Search Engines to the Custom Search Element. Now we are transitioning iframe CSEs as well. No work is required from CSE owners. Moving from the iframe option to the Element enables those CSEs to take advantage of our latest features, like automatic thumbnails."

read the rest @ http://googlecustomsearch.blogspot.com/2011/11/iframe-custom-search-engi...

I'm using the patch on 4 sites now with no issues.

smyleeface’s picture

#10 patch worked for me right away. Thank you! :)

omnia.ibrahim’s picture

Thanks gooddesignusa

I will try it...

omnia.ibrahim’s picture

Do you know how to change Ads location from being displayed at the top?

gooddesignusa’s picture

That might be an option on googles side. Log into googles custom search and look at the options

omnia.ibrahim’s picture

i searched their but its only for the iframe, by changing the FORID value, like the settings in the module, top, top right and right bottom. But i couldn't find that using Element.

It would be so grateful if anyone could tell me how to make it, i tried doing it using javascript and couldn't

lmakarov’s picture

@omnia.ibrahim - #12
Here's the patch that fixes empty search results
http://drupal.org/node/1268352

IntoTheWoods’s picture

Category: feature » bug
Priority: Normal » Critical

#10 works for me (patched against 6.x-1.x-dev) except that the custom Look and Feel as set on google.com/cse is not appearing (e.g. background color) even though it formats correctly on google itself.

I believe this is now officially a bug and not just a feature request with Google's deprecation of iframes.

TimG1’s picture

Hi All,

Patch in #10 on 6.x-1.x-dev (2011-Feb-25) worked for me too. Confirming same behavior as IntoTheWoods #20. Look and Feel showing up okay on http://www.google.com/cse but not coming across on my site.

Many thanks,
-Tim

sridarm’s picture

Thank you Gooddesignusa

gooddesignusa’s picture

I just took a look @ the patch file again and I indeed hard coded the Minimalist theme in. This initial patch was intended more for the maintainer of the module to realize iframe support was going to be depreciated. Since Google CSE has gone through some changes the admin area of this module needs some updating. My patch does not include any changes to the admin settings because I did not want to change to many things in the code without talking to the maintainer. Hopefully mfb will chime in soon.
Regarding changing the look of the results.
I logged into google CSE and messed around with the look and feel. It actually changes the javascript it wants you to include based on the settings you pick. If you customize the style it adds css to the code it wants you to insert into your site.
Tonight if I have time I will try to modify the patch to allow changing basic styles.
Another thing mentioning is I noticed if you set up GA for your search that is not getting included either. Since that also adds some things to the code it wants you to copy.

dunklea’s picture

Subscribing.

acidrainfall’s picture

@gooddesignusa, did you ever get a chance to look at this? I'm still having issues with it and would love some help.

teunis’s picture

StatusFileSize
new3.04 KB

Here's a Drupal 7 port, checks out for at least one site

hkirsman’s picture

Works for D7 but I've created new patch from #26 as it gave errors:
error: /google_cse_results.tpl.php: No such file or directory
error: /google_cse.theme.inc: No such file or directory

Should this patch be in separate issue (for D7)?

I create patch in google_cse dir with command:
git diff > patch_name.patch

I apply patch with:
git apply patch_name.patch

Would be curious how the #26 (google-cse-ajax.patch) was done.

Also this is good read (first link) https://www.google.com/search?btnG=1&pws=0&q=apply+patch+drupal

berenddeboer’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Reviewed & tested by the community

Much appreciated teunis and hkirsman, finally the module now works for me on D7.

hkirsman’s picture

Patch #27 uses V1 of "Custom Search Element Control API".

There's v2 out: https://developers.google.com/custom-search/docs/element

I haven't figured out how to remove default styles like in v1 ( just remove drupal_add_css('//www.google.com/cse/style/look/default.css', 'external'); )

eric.goodwin’s picture

Works like a charm.. Thanks!

vchen’s picture

Tried patch #26 and #27 and it semi-works. It got rid of the iframe, but it also got rid of the image search tab and "Sort by" options! Those are crucial features that we'd want to keep.

Also, (I guess this is not as important, since it's just CSS), but it doesn't take any of the changes I make in the Google CSE look and feel interface.

noobpal’s picture

Status: Reviewed & tested by the community » Active

I have installed this module and the patch #27 on a client's website. They purchased a paid version of the google site search. Everything seems to work fine at first, but eventually the search element breaks. There is no specific amount of time for the module to break. Sometimes it happens in a matter of minutes and other times it takes hours.

What happens is that the watermark that is added to the search forms on each of the pages disappears (this is my indicator that the search has broken again). Then if I go to the admin >> configurations tab and look at the search module settings, the checkbox for Google CSE under "ACTIVE SEARCH MODULES" and the radio button for Google CSE under "Default search module" have both disappeared.

All I have to do to bring these options and the watermark back is to disable and then re-enable the module. I am really confused by this apparent bug and would appreciate any help that is offered, since I am brand new to the world of Drupal and php programming. The client's site is currently running on Drupal version 7.7

hkirsman’s picture

Sounds like some D7 bug or database corruption. Not sure. I've had similar problems under Appeareance and with Omega theme. Also the problem you're describing hasn't happened on my sites.

Can you disable Default search module (can't remember if there are dependencies)?

stevendshelton’s picture

#27 worked for me. Thank you.

dww’s picture

Category: bug » task
Priority: Critical » Major
Status: Active » Needs review

a) Thanks for the patches. I was having the same concerns and problems with the iframe and was glad to find this issue.

b) #27 works okay for me on a D7 test site. Yes, the ability to sort results isn't happening, but I think 'needs review' is more appropriate. That patch could be cleaned up a bit (e.g. things that are commented out should be removed). But, it's basically working, so let's try to get it (or something like it) committed.

c) This is not a critical bug. The existing branch works fine. Sure, the iframe approach is sucky and deprecated by Google, but it does still work. ;) Let's call this a major task, instead. ;)

d) I took a very preliminary and quick stab at trying to get the v2 API working (thanks hkirsman for the link in #29!) and wasn't successful. I think #27 is a step foward over what's currently in the 7.x-1.x branch, so I'd support just getting it in and then working on v2 in a follow-up issue.

Thanks everyone!
-Derek

krlucas’s picture

Here's a D7 patch based on #27. It moves all the inline js into a js file and splits things into closures.

I have a client already using #27 so I'm not sure if this breaks the iframe fallback.

hcethatsme’s picture

#36 works for me, but I also needed to change 'http' to 'https' in google_cse.theme.inc (had been using the patch in https://drupal.org/node/2072029 ).

I know it's a problem to use http: inside an https page, but is there any issue with leaving it set to https inside a non-secure page? If so, it would be nice to have it as an admin setting. I might try that to get my feet wet, unless it's unnecessary. Thanks in advance for educating me!

hkirsman’s picture

Maby just use // istead of https:// or http:// ?

krlucas’s picture

@hcethatsme and @hkirsman

The patch in #36 already uses '//' for the external files so it should also take care of https://drupal.org/node/2072029.

Are you still getting insecure content errors with #36?

Kelly

afear’s picture

Issue summary: View changes

#36 works for us over https, i.e. no insecure content errors. Thanks for the patch! Should this be moved to RTBC at this point?

osopolar’s picture

Status: Needs review » Needs work

It seems that the patch in #36 is not using CSE but the Google Web Search API, which is deprecated, as stated in https://developers.google.com/web-search/docs:

Note: The Google Web Search API has been officially deprecated as of November 1, 2010. It will continue to work as per our deprecation policy, but the number of requests you may make per day will be limited. Therefore, we encourage you to move to Custom Search, which provides an alternative solution.

The deprecation policy says:

For a period of three years after an announcement (the "Deprecation Period"), Google will use commercially reasonable efforts to continue to operate the Deprecated Version of the Service and to respond to problems with the Deprecated Version of the Service deemed by Google in its discretion to be critical. During the Deprecation Period, no new features will be added to the Deprecated Version of the Service.

[Edit:] Actually I am not sure if Google Web Search API or CSE is used.

hkirsman’s picture

Haven't been in the project for a time but I think it is like I've said in the #29

So it's currently V1 of "Custom Search Element Control API".
https://developers.google.com/custom-search/docs/js/cselement-devguide

This thread has been up a bit too long (since March 20, 2011). :)

Taking account what osopolar just said about the deprecation policy, the current solution might not work tomorrow or in a year. We don't know. Fact is Google has deprecated it a long time ago.

I say we close this thead and start a new one with V2 implementation.

mxwright’s picture

Related issues: +#2422979: Integrate V2 code

I realize this thread is pretty old, but we've been using the patch in #27 for quite some time. Recently, I updated the patch to work with the latest V1 code, which has much more customization available. However, as alluded to in previous comments, V1 is too variable for a patch to account for every possible permutation and deprecation is always looming.

I went ahead and created a patch for the V2 code and put it in a new issue, as suggested by hkirshman:

#2422979: Integrate V2 code

Hope this works for anyone else in a similar situation.

alexmoreno’s picture

Status: Needs work » Closed (duplicate)