Advanced search on Google Sites
Enhance search on your site
Search results :
Tutorial
Here's an example where I let people search for files in a Drive folder:
Create the script
function doGet(e) {
var results = DriveApp.getFolderById('0B3xR7WfXrj7aQTc5NWNMOGtITGc').searchFiles('fullText contains "' + e.parameter.q + '"');
var app = UiApp.createApplication();
var panel = app.createVerticalPanel();
while(results.hasNext()) {
var file = results.next();
panel.add(app.createAnchor(file.getName(), file.getUrl()));
}
var scrollPanel = app.createScrollPanel(panel).setHeight(200);
app.add(scrollPanel);
return app;
}
The 'q' parameter is very important to trigger the search from Google Sites.
Embed this script in a Google Sites page
Create a page in your site and click on the menu Insert > Apps Script
This is not mandatory but it is better to show search results directly inside your site.
Add this search engine to your site
Click on the menu More > Manage Site
Click Configure Search, select the "Advanced" tab and choose the type "Google Search Appliance" as a Search Provider
Then add the url of the page where your script is embedded as the search engine url.
You have now a new search engine on your site