The ISearchable interface is used to allow the users of your module to search for content using the search mechanism provided by the DotNetNuke framework.
Most users are familiar with the search provided by websites such as Google.com
If you type in "create a DotNetNuke module" in Google you will see a list of websites that describe how to make DotNetNuke modules. If you type in "buy a DotNetNuke module" you will see sites that sell DotNetNuke modules. Google is able to understand (to the best of it's ability) what you are ultimately trying to find by searching through the entire contents of all the pages it has stored in it's database.
The search provided by the DotNetNuke framework doesn't work like that. It works more like an index in the back of a book. The only items in the index are items that the author (in this case the module developer) has decided to put there. The search merely allows DotNetNuke portal users to quickly find items placed in this index.
At first glance you might prefer the Google approach and not see the usefulness of the search provided by the DotNetNuke framework. However, like a carefully constructed index in a book, the DotNetNuke search allows the module developer to deliver helpful relevant results to search queries by only placing items in that index that a user would want to search on. In this case what you leave out is as important as what you put in.
For the Survey module it was decided that only the questions not the answers would be placed in the search index. This omitted such potentially repetitive and unhelpful words such as yes and no from cluttering up the search results.
To implement search for the Survey module we performed three steps:
When you look at the module definition for the Survey module, you can see that the controller class defined is DotNetNuke.Modules.Survey.SurveyController.
We opened up this class in the Visual Studio code editor and added this line at the top of the class and hit the Enter key.
Hitting the Enter key after we insert the line causes Visual Studio to insert a stub for the method.
Next, we add the following code to the method and save the page.
VB:Public Function GetSearchItems(ByVal ModInfo As Entities.Modules.ModuleInfo) _
publicSearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
We return to the module definition (for the Survey module) and click the Update link.
Searchable will now be checked under Supported Features.
The content will now be searchable.
To implement the search we performed three steps:
If you look in the object browser at the definition for the SearchItemInfo object you can see that it has a number of overloads.
The constructor we used has this signature:
Public Sub New(
ByVal Title As
The important thing to remember is that the SearchKey parameter must be a unique value. In this case we passed the contents of the SurveyId field (from the Surveys table) to the SearchKey parameter.
The Content is the content that the portal users will be searching on. We passed the contents of the Question field to the Content parameter. As you can see in the table schema below, the Question field has a direct one-to-one relationship with the SurveyID field.
This line adds the SearchItemInfo object to the SearchItemInfoCollection collection:
This line returns the SearchItemInfoCollection collection as the output of the method:
You could easily create your own search function. However, it would certainly require more code. In addition the Search functionality provided by the DotNetNuke framework searches across all modules (that implement the interface) at the same time.
This demonstrates yet another reason why you should consider leveraging the DotNetNuke framework for your next project to save time and money.
[Back to: The ADefWebserver DotNetNuke HELP WebSite]
DotNetNuke® is a registered trademark of Perpetual Motion Interactive Systems Inc.