It's no secret that DotNetNuke's core search leaves a lot to be desired. When implementing DNN sites or any site for that matter, search is typically a top requirement. To be perfectly honest, I have conveniently tried to leave off search functions from design comps or implementation plans because I dread the discussion that much (my conscience typically gets the better of me and we find a solution).
For more info on how the core search works check out this blog entry on DNN core search by Chris Hammond.
Well, I have found a solution that I'm pretty happy with and can confidently recommend as an implementation approach for DotNetNuke implementations - integrate a Google Site Search account with the core DNN skin object.
How is it done?
First, the core search token has a lesser known attribute UseWebForSite that allows you to integrate the core search token with your unique identifier with Google Site Search.
Setup Steps
- Create a custom search engine with Google Site Search. With the Site Search created, go to the Advanced section of the Control Panel for your custom search and grab the unique identifier (in a section titled “Advanced presentation using the Custom Search Element”)
- Add the search token to your skin and define UseWebForSite as “True” (see below). You can either do this through your HTML skin’s accompanying XML file or directly in the ASCX.
- Modify the resource file for the core search. You can reference the file directly from the file system (\admin\Skins\App_LocalResources), but it is better to go in through the Language Editor as a site administrator and modifying the Search.ascx.resx for just your portal (in case you have multiple sites in your instance of DNN).
- There is a field titled URL.Text. In this field, you can modify the existing URL to include the unique identifier for your custom search. The default uses the DNN project ID and should be something like: http://www.google.com/custom?hl=en&client=pub-9770992166002654&sitesearch=[DOMAIN]&q=[TEXT]
One thing to note is that I ran into some issues with the default URL in the resx file. So instead of modifying the existing URL, I went into my custom search engine home (with Google) and tested the search there. Then I took the URL created by Google and replace the search input with [TEXT]. This accomplishes the same result. Example: http://www.google.com/cse?cx=005560045880849113066:aqsy2ovgo00&ie=UTF-8&q=test&sa=Search and replaced q=test with q=[TEXT]
Other Notes
- The search launches the results in a separate window and some browsers will block this as a pop-up.
- The results can be styled using the Control Panel (Look & Feel) in Google Custom Search
- The results you get are the results Google indexes. So if you don’t like your Google results, you won’t like your Google Custom Search results.