DotNetNuke – Make Your Module Searchable
So far, you know everything you need to know to get a basic module up and running. There are a few items we still need to cover regarding the configuration of your module so that it can have different types of behavior with each instance, but before we get to that, there are a few more higher-level topics we need to discuss with regard to the main view module code. The first of those is how to make the module searchable.
In the original controller that the DotNetNuke module wizard created for you, the class inherits from the ISearchable interface. Because of this, the following method was also added to our controller:
public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo) { return null; }
This is the code we need to implement. Right now, it does nothing.
Our job is to create the SearchItemInfoCollection based on information that was passed in with the ModInfo parameter and return it from this method. For a simple module, this will be pretty easy.
The ModInfo parameter has a ModuleId hanging off of it that you can use to retrieve the data that will be in this instance of the module. Once you have the content, you create a SearchItemInfo object and pass in the module title, a description of the content, the user who created the content, the date the content was created, the moduleId, the content we want to be searchable, an optional parameter string and an optional image integer.
In many cases, your code will look like this:
SearchItemInfoCollection searchCollection = new SearchItemInfoCollection(); SearchItemInfo searchItem = new SearchItemInfo(title, description, author, DateTime.Now, ModInfo.ModuleID, string.Empty, Content, string.Empty); searchCollection.Add(searchItem); return searchCollection;
However, if your module takes parameters and could display different content based on those parameters, you will need to first retrieve all of the possible content from the database and put the searchItem and searchCollection.Add() code in a loop. This is where the searchKey parameter and the parameter string come in. (The parameter string parameter is called GUID… Charles or Joe, you want to jump in here and comment on why?)
Since each SearchItemInfo needs to be uniquely identifiable to the DNN search engine, we need to add something unique to the searchKey. It may just be a record number. When I created my store modules, I used TabID (also hanging off ModInfo) and ProductId (unique ID of the row I was adding) since it was possible for the row to exist on multiple tabs.
Since this is parameterized data, we need to tell the DNN search engine how to get to this data using a parameter. We do this by passing in the parameter information that will get us to this content. In my case, I set the itemid parameter to the productID to display the detail information of the product,
string guid = String.Format("itemid={0}", row.ProductID);
which I then passed into the GUID parameter so that my resulting searchItem constructor looks like:
SearchItemInfo searchItem = new SearchItemInfo(title, description, author, DateTime.Now, ModInfo.ModuleID, searchKey, Content, guid);
It’s been several years since I first figured this out, but I think it took me about a day to figure out that the GUID parameter was really a way to let the search engine pass a parameter to my data.
Other post in DotNetNuke - Module Development
- Creating DotNetNuke Modules - May 20th, 2008
- Creating DNN Modules - The Tools - May 22nd, 2008
- DotNetNuke Modules - Foundational Concepts - May 26th, 2008
- DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
- DotNetNuke Modules - Creating Base Modules - May 28th, 2008
- DotNetNuke Modules - Registering Your Module - May 29th, 2008
- DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
- DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
- DotNetNuke Modules - Anatomy of the View - June 9th, 2008
- DotNetNuke Modules - Adding Actions - June 11th, 2008
- DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
- DotNetNuke - Internationalization - June 25th, 2008
- DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
- DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
- DotNetNuke Modules - LinkButtons - July 14th, 2008
- DotNetNuke Modules - Collapsible Panels - July 16th, 2008
- DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
- DotNetNuke - Modules - Creating The Tables - July 24th, 2008
- DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
- DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
- DotNetNuke Modules - Data Access Layer - August 5th, 2008
- DotNetNuke Modules - Data Access Layer - August 7th, 2008
- DotNetNuke - Data Access Layer Alternative - August 12th, 2008
- DotNetNuke - Modules - Linking within the module - August 14th, 2008
- DotNetNuke - Make Your Module Searchable - August 19th, 2008
- DotNetNuke Modules - Making Content Portable - August 25th, 2008
- DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
- DotNetNuke Modules - PortalModuleBase - September 4th, 2008
- DotNetNuke Modules - Inter Module Communication - September 9th, 2008
- DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
- DotNetNuke Modules - Caching - September 17th, 2008
- DotNetNuke Modules - Module Settings - September 22nd, 2008
- DotNetNuke Modules - Retrieving Settings - September 24th, 2008
- DotNetNuke Modules - Advanced Architecture - October 20th, 2008
- DotNetNuke Modules - Creating the PA - October 30th, 2008
- DotNetNuke Modules - Automating the PA - November 5th, 2008
- DotNetNuke - FileUploadControl Danger! - February 26th, 2009
- DotNetNuke SecurityException AspnetHostingPermission - October 14th, 2009
- Changing an Existing DNN Module - March 4th, 2010
Other Related Items:
Transcend IDE Flash Module Vertical - Solid state drive - 512 MB - internal - IDETranscend's IDE Flash Modules are specially designed for use in the demanding industrial environments where industrial PCs, Set-Top Boxes and other computer systems must operate. IDE Flash Modules are a convenient and easy to use solution for expanding an industrial computer's memory capacity.
Beginner's ASP.NET in C# 2003 on DVDASP.NET 2003 represents an important technology for building enterprise level web applications. Learn the basics of ASP.NET development as you watch a... Read More >
Beginner's ASP.NET in VB.NET 2003 on DVDASP.NET (VB.NET) 2003 represents an important technology for building enterprise level web applications. Learn the basics of ASP.NET development as yo... Read More >









