How to Integrate Google Search in WebHelp Responsive Output
It is possible to integrate the Google Search Engine into your WebHelp Responsive output and you can specify where you want the results to appear in your WebHelp page.
Using a Publishing Template
To integrate the Google Search Engine into your WebHelp Responsive output
using an Oxygen Publishing
Template, follow this procedure:
- Go to the Google Custom Search Engine page using your Google account.
- Select the Create a custom search engine button.
- Follow the on-screen instructions to create a search engine component for your
site.Important: For the Layout, you must select Results only for the Google Search Engine to work with Oxygen XML WebHelp Responsive.
- At the end of this process you should obtain a code snippet that looks like
this:
<script> (function() { var cx = '000888210889775888983:8mn4x_mf-yg'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); } )(); </script>
- Save the script into a well-formed HTML file called googlecse.html.
- Open the template descriptor file associated with your publishing template and add the
webhelp.google.search.script
parameter in the parameters section with its value set to reference the googlecse.html file that you created earlier.<publishing-template> ... <webhelp> ... <parameters> <parameter name="webhelp.google.search.script" value="resources/googlecse.html" type="filePath"/> </parameters> </webhelp>
- You can also use the
webhelp.google.search.results
parameter to choose where to display the search results.- Create an HTML file with the following content:
<div class="gcse-searchresults-only" data-autoSearchOnLoad="true" data-queryParameterName="searchQuery"></div>
(you must use the HTML5 version for the GCSE). For more information about other supported attributes, see Google Custom Search: Supported Attributes. - Set the value of the
webhelp.google.search.results
parameter to the file path of the file you just created. If this parameter is not specified, the following code is used:<div class="gcse-searchresults-only" data-autoSearchOnLoad="true" data-queryParameterName="searchQuery"></div>
.
- Create an HTML file with the following content:
- Open the DITA Map WebHelp Responsive transformation scenario.
- Click the Choose Custom Publishing Template link and select your template.
- Click OK to save the changes to the transformation scenario.
- Run the transformation scenario.
Using a Transformation Scenario in Oxygen XML Editor/Author
To integrate the Google Search Engine into your WebHelp Responsive output
using a transformation scenario from within Oxygen XML Editor/Author, follow this procedure:
- Go to the Google Custom Search Engine page using your Google account.
- Select the Create a custom search engine button.
- Follow the on-screen instructions to create a search engine for your site.Important: For the Layout, you must select Results only for the Google Search Engine to work with Oxygen XML WebHelp Responsive.
- At the end of this process you should obtain a code snippet that looks like
this:
<script> (function() { var cx = '000888210889775888983:8mn4x_mf-yg'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); } )(); </script>
- Save the script into a well-formed HTML file called googlecse.html.
- Edit the DITA Map WebHelp Responsive transformation scenario and choose a template.
- Switch to the Parameters tab and edit the
webhelp.google.search.script
parameter to reference the googlecse.html file that you created earlier. - You can also use the
webhelp.google.search.results
parameter to choose where to display the search results.- Create an HTML file with the following content:
<div class="gcse-searchresults-only" data-autoSearchOnLoad="true" data-queryParameterName="searchQuery"></div>
(you must use the HTML5 version for the GCSE). For more information about other supported attributes, see Google Custom Search: Supported Attributes. - Set the value of the
webhelp.google.search.results
parameter to the file path of the file you just created. If this parameter is not specified, the following code is used:<div class="gcse-searchresults-only" data-autoSearchOnLoad="true" data-queryParameterName="searchQuery"></div>
.
- Create an HTML file with the following content:
- Click Ok and run the transformation scenario.