Bookmark and Share

Tuesday, January 08, 2013

How to use Google search engine in your DNN web site

Some days ago I made a great discovery… the Google Custom Search Engine http://www.google.com/cse/:

image

You can create a custom search engine dedicated to your web site, it’s free and it doesn’t show advertisings (if you don’t need them).

image

Configure your web site address:

image

Try the search :

image

Get the JavaScript code:

image

You can also customize how the search works, add autocomplete, synonyms, add specific pages from other web sites…

 

image

If you want to add it to DNN you can follow this simple steps:

  1. You need to add one custom page to DNN , this will be the page that will show the search results and you need to connect the DNN search field to the google custom search page.image
  2. Change the DNN search field, find the \DotNetNuke5\admin\Skins\Search.ascx.vb file and add this lines of code, a simple redirect to the new search page: 
           
    Protected Sub ExecuteSearch(ByVal searchText As String, ByVal searchType As String) 
    If Not String.IsNullOrEmpty(searchText) Then
    Response.Redirect("/tabid/<YOUR SEARCH PAGE ID>/default.aspx" & "?q=" & Server.UrlEncode(searchText))
    return



  3. The google search engine automatically uses the query string parameter as search word, you need to use the “q” parameter.



  4. That’s all!

No comments:

Post a Comment