If you get a "business" (paid) account on Google Custom Search, you are allowed to get search results via XML and display them in your site however you want, without ads, and without using JavaScript or iFrames.
I have successfully modified your google_cse module so that it can do this. Probably other sites would find this useful, so I thought I'd file a Feature Request with my changes.
I can attach a patch if you want, but there are so many changes I thought it might be simpler just to attach the rewritten module itself. Besides making this new display option, I also added a bunch of other options to the Settings page that allow you to customize more of the text in the output of the module. And since there were now a lot of options, I rearranged the options screen (added some more fieldsets and changed the order of some fields).
I will also attach a few lines to be added to the CSS file for the new display option.
I did this for a Drupal 5 site, so I have only done this for the Drupal 5 version of your module, but it would probably be good to do it for Drupal 6 as well. Feel free to use the code as you see fit, and let me know if you'd like the patches in a different format.
Comment | File | Size | Author |
---|---|---|---|
#31 | fixed-promotions-348311-1.patch | 9.3 KB | joshmmo |
#10 | 348311_google_cse_xml_results.2.patch | 22.15 KB | samc |
#8 | 348311_google_cse_xml_results.patch | 19.15 KB | samc |
google_cse.css_.txt | 111 bytes | jhodgdon | |
google_cse.module.txt | 25.6 KB | jhodgdon |
Comments
Comment #1
msteudel CreditAttribution: msteudel commentedAny chance to get this integrated? This is a great third option.
Comment #2
samc CreditAttribution: samc commentedI was hoping the CSE module did this, and am very glad to find this patch. I'd love to see it integrated in as well.
Comment #3
mfbA patch on drupal-6 would be preferred, otherwise I'll have to do a lot of work to integrate this.
Comment #4
samc CreditAttribution: samc commentedI've been playing with the XML feature and it works great.
In addition, I've further modified the code posted above to support the use of GCSE's labels and refinements. I.e. the "Refine your search for 'blah'" features.
I'm happy to share what I've got with anyone interested. I wasn't sure it made sense to post a patch against a patch, but once the base XML feature is integrated in I'd be happy to roll something.
Comment #5
mfbRather than posting a patch of a patch, just reroll the patch. But it also needs to be rerolled for d6.
Comment #6
jhodgdonSorry - my client's site was started a while back and was using D5, so that is why the patch is for D5.
Comment #7
redping CreditAttribution: redping commentedIs this change available for drupal 6 module? I only see that you can choose where you want the ads to be displayed and I don't see an option for using a business account
Comment #8
samc CreditAttribution: samc commentedI recently updated my site to 6.x and as result finally bit the bullet and updated the XML Results patch.
The attached patch contains the functionality of the original patch, along with my "refinements" feature and other fixes. Full themability of the results is provided as well.
I'd love to get some other testers/reviewers involved and eventually get this added to the module!
Comment #9
pottercreative CreditAttribution: pottercreative commentedReally nice patch. Working very nicely with the exception of an error that I'm not quite understanding how to fix.
warning: Invalid argument supplied for foreach() in /nfs/c04/h05/mnt/84547/domains/centerspace.net/html/modules/google_cse/google_cse.theme.inc on line 110.
Quick fix?
Comment #10
samc CreditAttribution: samc commentedThanks for posting! Yes, fortunately it's a quick fix. The original patch assumed that search refinement labels were present.
Updated patch attached.
Comment #11
pottercreative CreditAttribution: pottercreative commentedSam, thanks so much. Worked great. Had to uninstall, delete the google_cse directory, but I assumed that's what I needed to do before applying the patch.
Another question. I'm trying to display the search box block in the header region of my site so it's persistent across all pages. Not having much luck. Does this require the Drupal Core 'Search' module to be enable or am I having other issues?
Also, wondering if I can modify the code so that the search results resolve to /search instead of /search/google
Thanks for your help.
Cheers,
Ben
Comment #12
samc CreditAttribution: samc commentedThe search form is built into our site's template, so I haven't run into that issue. You can see it on the site here: http://www.appistry.com.
You should be able to drop some HTML into a custom block to accomplish the same thing. Here is the HTML from our site:
There is a preference that allows you to change /search/google to /search/something-else. I have mine set to "g" as it seemed less intrusive. I haven't looked into trying to override the default search so that this isn't necessary.
Comment #13
BenK CreditAttribution: BenK commentedSubscribing and will test....
Comment #14
kim.pepperSubscribing
Comment #15
scip CreditAttribution: scip commentedThanks, this is working for me, with the following issues:
Comment #16
webdrips CreditAttribution: webdrips commentedThis is a great module and a great patch, so first off, thank you all for both the module and patches!
However, as @scip pointed out, the patch in #10 doesn't work unless the optional google.module is disabled.
Unfortunately, I need this optional module to be working. I'm going to see if I can dig up the answer, but if someone can shine some light in the meantime, it would be most appreciated.
(I had the free Google version and made some mods to both .module files to use the site search box to display the Google results without all the extra tabs.)
Thanks in advanced,
Dan
Comment #17
samc CreditAttribution: samc commentedI looked into these issues this evening. It looks like:
1. The admin setting that allows you to change your search path (e.g. from 'search/google' to 'search/g') didn't survive the update to D6.
2. That setting is incompatible with the D6 core search system, and thus incompatible with the google.module that is included in CSE.
3. I have verified that after deleting the variable
google_cse_results_path
, or setting it to the default 'search/google', the patched CSE module seems to work fine with the google.module for me.Because of #1, I wouldn't expect anyone who applies the patch to see #2, so I'm left wondering if either of you (@scip or @daneesia) manually set
google_cse_results_path
by any chance? Can you verify that the variable either isn't set or is set to the default?Sam
Comment #18
webdrips CreditAttribution: webdrips commentedThanks for your help samc!
Note: I'm using the patched version of 6.x-1.2 instead of the patched dev version if that makes a difference.
Here's what I find strange now that you brought it up: with a quick search across all files for "google_cse_results_path", all the results I get are:
variable_get('google_cse_results_path', 'search/google')
.Yet when I insert the following into the theme file:
<?php print 'path: ' . variable_get('google_cse_results_path'); ?>
, I get "path: ", so it seems that somehow the variable is getting nulled out.Not sure what's going on, but when I add
<?php variable_set('google_cse_results_path', 'search/google'); ?>
, followed by the print statement, I get "path: search/google"....maybe a bug with variable_get()? Isn't it supposed to set it to the second argument if the variable is null?Comment #19
samc CreditAttribution: samc commented@daneesia:
Nothing strange about what you're seeing.
variable_get
returns the value of the variable name passed as the first arg, or the second argument if the variable isn't set. It does not ever set the variable, just returns a default value. Remember to issuevariable_del
to delete the value you set.You mentioned modifications to google.module and google_cse.module. Are you experiencing problems with the modified version, or with 6.x-1.2 and the applied patch #10?
When you say "I had the free Google version...," are you now using a paid Google Custom Search account? I think that's the only way you can get XML results.
When you say the "patch doesn't work," what exactly are you seeing? Is the site available publicly?
Comment #20
webdrips CreditAttribution: webdrips commented@samc ahh that makes more sense reg. variable_get().
I put the original files back in place and then applied the patch again (to ver 6.x-1.2) and I was back to another issue I was seeing originally seeing: the search uses the javascript/iFrame solution (and yes with the "On this site (without JavaScript or frames, requires current Google Business account)" selected).
In any case, that did not help as I had to disable the optional module to get it to display the XML-based results. So out of the box, there is an issue with 6.x-1.2 and the applied patch.
Yes I am now using the paid account (and it works so long as the optional module is disabled).
I can send you a private message with the site name if needed.
Thanks again,
Dan
Comment #21
webdrips CreditAttribution: webdrips commentedUpdate:
So I decided that maybe I don't really need google.module, so I disabled it along with the Drupal search module, but there are a few more things that don't appear to be working (but that did work with the google.module and search.module enabled).
The most important is the sitesearch parameter is being ignored.
There are other issues, but right now, that is the most important.
As always, any help is most appreciated.
Thanks,
Dan
Comment #22
webdrips CreditAttribution: webdrips commentedFound the issue: seems
_google_cse_get_search_results()
was not designed to handle the sitesearch variable (and other variables I'm guessing but will report back on that tomorrow).Here's my basic hack of the $query array (with the sitesearch key added):
Note: results only applied to first page, so Next page link is not carrying the entire query string...will research that as well.
Comment #23
dkinzer CreditAttribution: dkinzer commentedI was just about to start coding this feature when I found this patch. Thanks! So, does anyone know if it's ever going to be committed or at least made into it's own separate module?
Comment #24
rp7 CreditAttribution: rp7 commentedsamc, great work on the patch, thanks a lot for the effort.
Unfortunately I'm still experiencing the error message patch #2 was supposed to fix.
"# warning: Invalid argument supplied for foreach() in ...\sites\all\modules\google_cse\google_cse.theme.inc on line 124."
Note however, this message appears pretty random, let's say after every few searches. I can tell when this message will pop up before the page is loaded because it takes a bit longer - looks like there is some sort of time-out and no search results are getting returned by Google.
Any idea what the cause might be?
Comment #25
mfbif someone could provide me with (temporary) access to business custom search, I could work on support for this feature in the drupal 7 branch. I'm guessing it wouldn't take me long at all given that I've already got the Bing search API working over here.
Comment #26
enrique.delgado CreditAttribution: enrique.delgado commentedIf you still need access to a business account, I can help you with that. I'd love to see this being an option for D7.
Comment #27
joshmmo CreditAttribution: joshmmo commentedI am having this same issue:
It has been working for 8 months just fine and now today I notice the error. It happens on every search I try. I am using drupal 6, with google cse paid version:
"On this site (without JavaScript or frames, requires current Google Business account)".
Anyone have any ideas on where to look to fix this issue?
Thanks
UPDATE: Looks like it was an issue with our host, rackspace. They had an outage yesterday that caused outbound traffic to timeout.
Comment #28
rooby CreditAttribution: rooby commentedThe Google CSE Advanced module allows you to use the paid version.
There should be a D7 version soon (there is already one in the issue queue).
Comment #29
jhodgdonThat's annoying that there are two separate modules. If possible, they should be combined. :(
Comment #30
rooby CreditAttribution: rooby commentedI agree, it would be much better if there was only one module. Much less confusing and easier to switch between free & paid.
Plus the usual defragmentation benefits.
I was planning to spend a bit of time getting the CSE advanced port up to scratch for drupal 7 but I might make some time to try this out and get a drupal 7 version of the patch going.
This route will take me more time though so I will have to see how I go for time.
Comment #31
joshmmo CreditAttribution: joshmmo commentedThis patch gave issues with promotions enabled. I did a fix. Just need to make changes in google_cse.module
Comment #32
joshmmo CreditAttribution: joshmmo commentedIf that patch fails for you, you can see my new google_cse.module file here:
http://snipt.org/IIgj4
You will notice I switched to SimpleXML parser. This solved a few issues with promotions due to title not being wrapped in CDATA.
Comment #33
malcomio CreditAttribution: malcomio commentedSee the google_cse_adv module, which has been integrated with this in the D7 version.
Comment #34
rooby CreditAttribution: rooby commentedAlso check out the https://www.drupal.org/project/gss module.