A good search is a prevalent theme in all of the websites I implement. Google has set the bar high in terms of expectations for what search can do. The core search in DotNetNuke doesn’t come close. So as the phrase goes “if you can’t beat ‘em, join ‘em.”
Previously, I have written about how you can use the core search in DNN to integrate with a Google Custom Search engine API. If you’re interested in this approach, check out my blog post on integrating DNN search with the Google Site Search. This approach is nice, but it also is a little clunky to setup and the results launch in a new window. My new favorite way to use Google in a DNN site is to utilize the AJAX search feature provided by Google.
Have you ever typed “site:www.patrickrenner.com” into Google? It allows you to simply search a single site using the indexing of Google. The AJAX search basically does the same thing. It takes the URL you wish to search and appends your search parameters on to the request to Google.
To make this happen in DNN, there are three things you’ll need to do.
- Insert an input into your skin. This will act as the search input for your site. The values included in the input will be the values past to the search query.
- Include an empty <div> in which you wish to place the results of your search.
- Add the JavaScript to your skin which allows for the input, the results div, and Google to all cooperate.
Instead of spelling out the code, I’ve included a text file for you to download to reuse this code for your site. Download the example code here. Feel free to inspect my site as well to see the code in action.