This tutorial will show you how to add a 
Google Custom Search box to horizontal navigation bar, just like what you see here in Blogger Sentral. (Google Custom Search enables you to search within a collection of blogs or websites of your choice).
Step 1. Create your custom search engine
For the custom search to work you need a Google custom search engine to go with the search box. Follow the steps below to create one.
Note: This tutorial is not applicable to Search Box gadget added via Design > Page Elements.
- Go to Google Custom Search to create a custom search engine.
- If your are an Adsense publisher you can also use Adsense for search. 
- Configure the search engine and get the code for the search box.
- Look for the search engine unique ID in the code. It should look something like this: 006442829066104501157:setkk2xdqoior this:partner-pub-4409159435154980:sle4z0smh1f
 
We are only interested in this ID, the rest of the code is of no use. 
Step 2. Create the search box
This is the code for the search box:
| 02 | <divclass='cse'style='color:#000000;float:right;margin:6px 10px 0 0 ;'> | 
 
| 03 | <formaction='http://www.google.com/cse'id='cse-search-box'> | 
 
| 04 | <inputname='cx'type='hidden'value='partner-pub-4409159435154980:sle4z0smh1f'/> | 
 
| 05 | <inputtype='text'name='q'size='35'/> | 
 
| 06 | <inputname='ie'type='hidden'value='ISO-8859-1'/> | 
 
| 07 | <inputtype="submit"name="sa"value="Search"/> | 
 
| 09 | <scripttype="text/javascript"src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script> | 
 
 
 
Mar. 2011: Code updated to include Google Custom Search logo and search button. 
Dec. 2010: Code update.
- Replace the value of valueattribute in line 4 with the Search engine unique ID from Step 1.3.
- To make the search results appear in a new window, just addtarget="_blank"before the closing bracket in line 3.
- You can modify the search text box width by changing the value of sizeattribute in line 5.
Step 3. Add search box to navigation bar
The steps below will place the search box on the right hand side of the bar.
- Login to your Blogger account.
- Go to Dashboard > Design > Edit HTML.
- Back up your template.
- Tick the  Expand Widget Templates check box on top right of the HTML window.
- If your navigation bar is made of Pages gadget, look for this code: 
 
| 1 | <b:widgetid='PageList1'locked='false'title='Pages'type='PageList'> |  
 
 
| 2 | <b:includableid='main'> |  
 
 
| 3 | <b:ifcond='data:title'><h2><data:title/></h2></b:if> |  
 
 
| 4 | <divclass='widget-content'> |  
 
 
| 6 | PUT THE SEARCH BOX CODE HERE |  
 
 
| 7 | <b:loopvalues='data:links'var='link'> |  
 
 
 
 
- Insert the search box code from Step 2 right after the <ul>line.
- If your navigation bar is made of a LinkList gadget, look for LinkList(instead ofPageList) in line 1.
 
- Preview before saving.
 
 
No comments:
Post a Comment