DokuWiki and Google CSE with a stand-alone search result page
Integrate the Google CSE (Custom Search Engine) in your DokuWiki installation with a stant-alone search result page (adapted from Google CSE - Implementing search box).
Add a CSE script
Copy and paste this code in your meta.html
hook present in your template directory (<dokuwiki>/tpl/<template>/meta.html
):
<script> (function() { var cx = 'YOUR_ENGINE_ID'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script>
Configure the CSE
Select and save the two-page layout in the Google CSE Control Panel. On one page, implement a stand-alone search box, changing the resultsUrl
attribute to point to the url where you want to display the results (eg. http://example.org/dokuwiki/search).
Edit your sidebar page
Copy and paste this code in the sidebar (or in one of many hooks or in your preferred location):
<gcse:searchbox-only resultsUrl="YOUR_RESULTS_PAGE_URL"></gcse:searchbox-only>
Create a stand-alone search result page
To implement a stand-alone search results page, create a new DokuWiki page (eg. search) and paste the results code snippet into your results page:
<gcse:searchresults-only></gcse:searchresults-only>
Now you can trigger search results on this page by passing a q
argument in the url:
http://example.org/dokuwiki/search?q=myQuery
<html>
tag, enable the config:htmlok option.