This interface allows module developers to implement a common collection of items that DotNetNuke can index and provide via the search results module.
Example Code (VB)
'/// -----------------------------------------------------------------------------
'/// <summary>
'/// GetSearchItems implements the ISearchable Interface
'/// </summary>
'/// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param>
'/// -----------------------------------------------------------------------------
Public Function GetSearchItems(ByVal ModInfo As ModuleInfo) As SearchItemInfoCollection Implements ISearchable.GetSearchItems
Dim searchItemCollection = New SearchItemInfoCollection()
Dim colArticles As List(Of Article) = ArticleController.GetArticles(ModInfo.ModuleID)
For Each objArticle As Article In colArticles
Dim searchItem As New SearchItemInfo
searchItem.Title = objArticle.Title
searchItem.Description = objArticle.Description
searchItem.Author = objArticle.CreatedByUserId
searchItem.PubDate = objArticle.LastModifiedOnDate
searchItem.ModuleId = ModInfo.ModuleID
searchItem.SearchKey = objArticle.ArticleId.ToString()
searchItem.Content = objArticle.Body
searchItem.GUID = "aid=" + objArticle.ArticleId.ToString
searchItemCollection.Add(searchItem)
Next
Return searchItemCollection
End Function
Example Code (C#)
/// -----------------------------------------------------------------------------
/// <summary>
/// GetSearchItems implements the ISearchable Interface
/// </summary>
/// <param name="modInfo">The ModuleInfo for the module to be Indexed</param>
/// -----------------------------------------------------------------------------
public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
{
var searchItemCollection = new SearchItemInfoCollection();
List<Article> colArticles = ArticleController.GetArticles(modInfo.ModuleID);
foreach (Article objArticle in colArticles)
{
var searchItem = new SearchItemInfo(objArticle.Title,
objArticle.Description, objArticle.CreatedByUserID, objArticle.LastModifiedOnDate,
modInfo.ModuleID, objArticle.ArticleId.ToString(), objArticle.Body, "aid=" +
objArticle.ArticleId);
searchItemCollection.Add(searchItem);
}
return searchItemCollection;
}
Example Source Project
The example code from this project can be found on
http://dnnsimplearticle.codeplex.com References