Allowing simple Web searches

Name

'Simple' Google Search

Module Type

Block

Author

Mike Burke

Released

2009

Maintained

Actively (although there's not much to it)

Languages

English (fixed in code)

Compliance

No internationalization

Documentation

None

Errors

None

The 'Simple' Google Search block is a block that allows users to type in terms that will be sent to the Google web search page.

Getting ready

Install the block into the /moodle/blocks/ directory and visit the Notifications page.

How to do it...

Once installed, there are no configuration settings and no help files. There is just a textbox used to enter terms which are sent to the Google search engine. Results appear on a new tab or browser window.

How to do it...

If you want to change the behavior or the language for this block, you need to be prepared to edit the block code. The source of the block is contained in a single file called block_simple_google.php. Within the file there are lines of HTML that define the appearance of the block when it is rendered on a course page.

$this->content->items[] .= "<!-- Google Block By Panic Software-->
<center>
<form action='http://www.google.co.uk/cse' id='cse-search-box' target='_blank'>
<div>
<input type='hidden' name='cx' value='partner-pub-6254809892762656:bfrdgi-tjfn' />
<input type='hidden' name='ie' value='ISO-8859-1' />
<input type='text' name='q' size='31' />
<input type='submit' name='sa' value='Search' />
</div>
</form>
<script type='text/javascript' src='http://www.google.co.uk/cse/brand?form=cse-search-box&amp;lang=en'></script>
</center><!--End of Google Block-->";

At present, the block refers all queries to http://www.google.co.uk/. You might want to change to your local Google search engine for faster queries and possibly to receive more relevant search results. For a generic solution that works anywhere, replace the current form action attribute http://www.google.co.uk/cse with http://www.google.com/# and the Google server will redirect you to your local Google server based on your physical location.

The block currently forces a wider than normal width. This is because the text input with name q has a size of 31 characters. This doesn't restrict the number of characters that can be entered, it just sets the width of the textbox. You could reduce this to a smaller number of characters, but a better way to fit the textbox to the block is to remove the size attribute size='31' and replace this with a style attribute that will resize the textbox relative to the block style='width:99%'.

If you want to change the label of the Search button, find the line<input type='submit' name='sa' value='Search' /> and change the word Search to other words, or another language if desired.

If you would like to remove the branding from the textbox, remove the starting and ending script tags near the end of this section of code.

How to do it...

Note

You are within your rights to modify core and contributed Moodle code. However, you should be aware that this comes with some risk. Apart from possible unexpected side effects, once you have changed a module, if you update the module in future, the module code will be overwritten and you will need to re-do any changes you previously made.

While this block is simpler than the Moodle Google block described earlier, it is immune to changes in the Google Search API. While it is less convenient to view search results outside Moodle, users will eventually be viewing pages linked from search results anyway, so perhaps that is not a great inconvenience. What this block lacks is configurability, so it is not as easy to direct students to particular searches.

See also

  • Moodle Google block
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.217.17