How do I add Google search capability to my site?

How do I add Google search capability to my site?

by Matt (M) -
Number of replies: 19
I see that moodle.org has a Googled-flavored search capability on their site. How can I ad this to my site, for moodle purposes as well as other server apps/systems that I run?

-Matt
Average of ratings: -
In reply to Matt (M)

Re: How do I add Google search capability to my site?

by Matt (M) -
Sorry if this was the wrong forum for this stuff...I couldn't find something that seemed to fit better. Maybe the installation forum?

Maybe someone can move this thread to the installation forum?

-Matt
In reply to Matt (M)

Re: How do I add Google search capability to my site?

by Tom Murdock -
Matt, this is totally new stuff. I think Martin added it within the past 24 hours.  When we know more about it, we'll pass it along.
In reply to Tom Murdock

Re: How do I add Google search capability to my site?

by Matt (M) -
Sounds good. I'll await the word.

Fyi, I'm particularly interested in whether or not this google search stuff is 1) purely software-based, as in I can plug in a software module and away I go (I would not want to get this away for free if I were google...but I'd sure love to get in on that action if I could!), 2) requires a "service" tie-in to their website (and thus might generate ad revenue for them), or 3) requires the dreaded "google search appliance," which is a hardware/server mechanism and costs big bucks (for typical accounts, anyway)....or something else?

-Matt
In reply to Matt (M)

Re: How do I add Google search capability to my site?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I didn't write the Google block, but Dave Scotson a colleague of mine did, and I looked over his shoulder quite a bit so I'll try and explain...

It's (reasonably) simple block that enables you to have a google search on your home or course pages. It uses existing Google features in its entirity. It can restrict it's search to just your Moodle site *if* (and only if) your moodle site is not sitting on a virtual directory (ie, http://www.mysite.ac/ not http://www.mysite.ac/moodle) as Google doesn't do that.

It will also automatically pick up your selected language, translate it to the equivalent Google language and restrict the results that way. That's it - it's work in progress really though.
In reply to Matt (M)

Re: How do I add Google search capability to my site?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The Google search just calls Google with the same parameters that you can type into the orginal Google search form.

I started with David's block but trimmed it right down for moodle.org. David's original is here and is easy to modify to your tastes.
In reply to Martin Dougiamas

Re: How do I add Google search capability to my site?

by Trizit Benjaboonyazit -

The translation of search forum in Thai misleads users into thinking that he will get information from the entire site.  Because it was cut short as "search" only in Thai.  Who do the translation for you.  and how can I contribute.

I have downloaded David'sscript on google search, but can anyone tell me how to add this block to moodle front page.



In reply to Trizit Benjaboonyazit

Re: How do I add Google search capability to my site?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Please raise the language issue on the Thai forums.

To install the block, you need to create a new folder in 'blocks' called "google" and put the script in there, called "block_google.php".

A proper blocks repository will be implemented as soon as someone writes one.  wink

In reply to Martin Dougiamas

Re: How do I add Google search capability to my site?

by Trizit Benjaboonyazit -
You are very  nice and helpful.
I managed to show it up after modifying some parts the script to accept Thai search.
For those who are interested, please see http://elearning.bangkaew.com/
In reply to Trizit Benjaboonyazit

Re: How do I add Google search capability to my site?

by David Scotson -

I think you've got a couple of minor problems in your code here:

<input name="hl" type="hidden" id="hl" value=\"th\">

The extra slashes around the th prevent Google showing it's Thai interface. There are similar extra slashes in the lines specifying encoding:

<input name="ie" type="hidden" id="ie5" value=\"windows-874\">
<input name="oe" type="hidden" id="oe2" value=\"windows-874\">

Also, Google can't search in areas smaller than a domain so each mention of "http://www.bangkaew.com/elearning" should really be ".bangkeaw.com" or elearning.bangkeaw.com"

In reply to Martin Dougiamas

Re: How do I add Google search capability to my site?

by Julian Whitehead -
Sorry, this is quite an old thread.
I want to add a google search to site, I have followed the instructions as provided by you fantastic people.
1. Created google folder in blocks.
2. Placed block_google.php in folder.
3. Go to add block and its not there
Is there something else I need to do?
Or am I just being really think?
Cheers
Jools
In reply to Julian Whitehead

Re: How do I add Google search capability to my site?

by Tony Hursh -
You probably need to visit your admin page before the block will be installed.

That got me the first time I tried to install a custom block.

smile



In reply to Tony Hursh

Re: How do I add Google search capability to my site?

by Julian Whitehead -
Thanks, in fact shortly after I posted, I managed to get it to work (Fool)!
Thanks for the help
Jools
In reply to Julian Whitehead

Re: How do I add Google search capability to my site?

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi,

although not directly related, some time ago I wrote an alternative Google's block using APIs from Google. Its main difference is that you can show results inside Moodle.

It can be tasted here.
(l/p: moveblocks)

And source code is available in contrib directory.

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: How do I add Google search capability to my site?

by Andrea Bicciolo -

Hi Eloy. Amazing this Google block with result inside Moodle. Just a question: it is possible to add an option such as "search the web" and "search this site". Would be tremendous, I think. smile

Are you using another browser than IE6? I'm getting a Javascript error "Identifier required", row 93 Char 32 code 0 in IE6 when accessing the result pages. IE6 oddity I think.

In reply to Andrea Bicciolo

Re: How do I add Google search capability to my site?

by Tom Murdock -
Am I still correct in thinking that this works only for sites "opentogoogle" as identified in the site variables?

http://moodle.org/mod/forum/discuss.php?d=11264
In reply to Tom Murdock

Re: How do I add Google search capability to my site?

by David Scotson -

Yes, in order for Google to index your site it needs access and then any member of the public can read your content on Google.

However they do sell a Google-in-a-box search appliance for intranets that could probably be hooked up in a similar manner. A new cut-down version was just introduced at a cost of only $5,000 (maybe they do an educational discount too. edit: I just checked, they don't sad).

http://www.google.com/enterprise/

The equivalent open source solution for institutions is probably to have a separate Java machine running a Lucene (using one of the PHP based interfaces for more control) or perhaps Nutch (which would spider the entire web interface just like Google)-based search engine and hooking it up in the same way as Google. However these solutions are probably useless in standard hosting situations.

Unfortunately PHP's Unicode-issues seem to have left it behind the state-of-the-art in search technology so SQL based searches are probably the best you can hope for at the moment in a pure PHP environment.

In reply to Andrea Bicciolo

Re: How do I add Google search capability to my site?

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Andrea,

the javascript problem should be solved now (I haven't IE to test it!) both in contrib and in the test site.

About the "search this site" option, I've to examine Google's API to see it it's possible but I haven't time to do it just now. I've a new Post-It in the wall remembering it! wink

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: How do I add Google search capability to my site?

by David Scotson -

Note that the external results, as seen here on Moodle.org's Google search, can be modified to look like your own site to some degree by logging into Google and providing a header, footer and color options (these details from memory) despite the results actually being hosted on google.com.

However, the result is not anywhere near as seamless as the Google API approach shown above.

In reply to Matt (M)

Re: How do I add Google search capability to my site?

by David Scotson -

I didn't notice this question last week but the Google search uses code straight from the Google mothership. You can use it without paying for anything. There is a Terms of Service document, but I believe that only applies if you use the more advanced forms and customise the search results page and/or try to gain ad revenue from the ads displayed alongside the results.

There's lots more info (including links to the Google pages about this) in the thread where I originally posted my code though you may prefer to get the code straight from Moodle's CVS where I assume Martin's version is available.