Google Custom Search Engine - r#d

Deprecation Application programming interface Method Computer Software,  text, logo png | PNGEgg
To add a Google Custom Search Engine to your site, you need to create a gadget. Below you will see the code for the CSE I use on this site. Just copy the code, change the highlighted part to the code for your CSE (use V1 code and specify protocol relative), store it somewhere online as an .xml file and put it on your Site (Insert>More Gadgets>add gadget by url and specify the url where you have stored it)

Searches this site and other Google Sites help sites

<?xml version="1.0" encoding="UTF-8" ?>
  <ModulePrefs title="Hello World!" />
  <Content type="html">
      <div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="//" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
    var customSearchControl = new'010428851484230611414:dbm31yqzwea');
    var options = new;
    options.enableSearchboxOnly("", null, true);
    customSearchControl.draw('cse-search-form', options);
  }, true);

Simple Gadget Creation and hosting

  1. Create a new XML file (can be a text file with file extension of .xml) in any text editor such as Notepad - save with UTF-8 encoding.
  2. Copy and paste the following base code for the gadget into the text editor:

    <?xmlversion="1.0" encoding="UTF-8"?>
    <ModulePrefs title="Custom Gadget" />
    <Content type="html"><![CDATA[
    Insert the custom content, script, JavaScript, CSS ad code, tracking code or other code here...

  3. Replace the “Insert the custom content, script, JavaScript, CSS ad code, tracking code or other code here…” with the actual code to display by the gadget on the web pages hosted on Google Sites.
  4. Replace the “Custom Gadget” with your preferred title for the gadget.
  5. Save the file with any file name with .xml extension to make it a gadget. For example, gadget.xml.
  6. Upload the .xml gadget to an online website.
  7. To host at Google Sites, create a page or edit an existing page, then add the file as an attachment.
  8. Copy the url of the gadget. If hosted on a Google site, right click on the download link and 'copy link address'
  9. Insert>More Gadgets>add gadget by url and specify the url from step 8.

Philip Ridout,
10 Nov 2012, 07:57