Have visitors search your website with Google Site Search
This package uses the Google Site Search to execute keyword searches on your website.
Please note that Google Site Search is a commercial edition of Google Custom Search. Your website should be registered with a paid Google Site Search edition. The free Google Custom Search Standard Edition does not work with the package.
Technical Information
The package provides the functions that uses Google Site Search API to retrieve and display the search results. Once you have created your Google Site Search engine, you get a search engine unique ID (similar to '003098970302671473565:zufgbcyhdqs'). You should use this unique ID as a required parameter in the function.
The function features a search box, too. If you need the search box on multiple pages, consider adding a simple HTML form in the website template(s) as described below.
How to implement search results on a page
- Get the search engine unique ID .
- In the Content perspective, edit a page that will serve as the page for search results.
- Insert the Composite.Search.GoogleSiteSearch.SearchResult function or add the following code:
<f:function name="Composite.Search.GoogleSiteSearch.SearchResult" xmlns:f="http://www.composite.net/ns/function/1.0"> <f:param name="SearchEngineId" value="003098970302671473565:zufgbcyhdqs" /> <f:param name="TextTitle" value=""{0}" - Search" /> <f:param name="TextResults" value="{0} results for <em>"{1}"</em>" /> <f:param name="ResultsPerPage" value="10" /> <f:param name="TextNoResults" value="No results for <em>"{0}"</em>" /> <f:param name="TextSuggestion" value="Did you mean " /> <f:param name="TextButtonSearch" value="Search" /> </f:function>
- Specify the required parameter:
- SearchEngineId: The parameter specifies a unique code that identifies a custom search engine for your website
- Optionally, specify these parameters:
- SearchTerm: The word or phrase to search for. By default the 'q' query string value will be used.
- ResultsPerPage: The number of search results to display on the page ('10' by default)
- If necessary (e.g. for localization), change the texts displayed with the search results.
How to add the search box to multiple pages
To display the search box on multiple pages:
- In the Layout perspective, edit the template(s) these pages are based on.
- Insert the following HTML form markup where necessary:
<form action="/page(f757961f-21c0-46c8-963e-a24b1d990cdb)" method="get" id="gss"> <input name="q" type="text" value="Search" /> </form>
- In the action attribute, specify the page with the Composite.Search.GoogleSiteSearch.SearchResult function (Insert | Page URL).
- Save the template(s).
How to localize the search results
As you provide new text strings, remember to use the system-defined parameters presented as {0}, {1} etc where appropriate within the strings.
- Edit the Composite.Search.GoogleSiteSearch.SearchResult function
- Select, and change the text in, the following parameters:
- TextTitle: The text in the page title. By default '"{0}" - Search' where {0} stands for the search term specified.
- TextResults: The heading for the search results. By default '{0} results for <em>"{1}"' where {0} stands for the number of results and {1} - for the search term specified.
- TextNoResults: The heading for no results. By default 'No results for <em>"{0}"' where {0} stands for the search term specified.
- TextSuggestion: The text used with the suggested search term. By default 'Did you mean <em>"{0}"?' where {0} stands for the search term suggested.
- TextButtonSearch: The text on the Search button ('Search' by default)
Important notes
- The free Google Custom Search Standard Edition does not work with the package.
- Your website should be registered with a paid Google Site Search edition.
- You should get the search engine unique ID (similar to '003098970302671473565:zufgbcyhdqs').
- You should keep the system-defined parameters presented as {0}, {1} when changing the text strings for the search results.
Customization
You can customize the layout of the search results by editing the style sheet:
~\Frontend\Composite\Search\GoogleSiteSearch\Styles.css
Requirements
Composite C1 version 2.0 SP 1 or later