Google Custom Search
Create your search engine
- Go to www.google.com and click "Sign In" (top right corner)
- This is the familiar gmail sign-in. When done, however, you will return to the google home page.
- Click "My Account" (again, top right corner)
- Under "Try something new", click the link that says "more »"
- Choose "Custom Search" from the left column.
- Click "Create a Custom Search Engine".
- For Search engine name, enter "yourname.com Search Engine" where yourname.com is replaced with your actual domain name (seach engine escription can be blank)
- The custom search will search "Only the sites I select".
- Enter your URL in the box for sites to search: http://www.yourname.com
- Select "Standard Edition" and check "I have read and agree to the terms of service".
- You can now try out your new search engine. Be aware that if you have only recently added your site to google, this may not yet yield results.
- Click "Finish". This will send a confirmation email to your gmail account.
Edit and "install" your search engine
- Next, you'll see a page where you can edit this search engine by clicking "control panel".
- Under "Indexing", there is an option to index certain pages now. I recommend entering your major site pages, one per line (essentially, this is entering a "site map" to search"). Once your site has been indexed, there will be search results.
- Under "Look and Feel" you can change the way the search results will look. This might be necessary once you add the search results display to your site.
- Under "Code", you can get code to add to your website so that the results are displayed on your own page. Select "Host results on your website".
- Use the "iframe" approach. This will yeild two snippets of code.
- The search box code should be added to your template. You may have to do some design manipulation to make it fit nicely. I recommend putting it in the sidebar or the header. Make sure to change the "action" part of the form code to "/search.php":
<form action="/search.php" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="CUSTOM_STRING_OF_DIGITS" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" value="Search" />
</div>
</form> - The result code goes in it's own page, something like this (create a new page, search.php)
- <?php include_once(_head.php'); ?>
<title>Search Results</title>
<?php include_once('_top.php'); ?>
<div id="cse-search-results"></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 600;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
<?php include_once('_bottom.php'); ?>