• 4/7/2015
  • 3805 Views

Comments

3805 Views

ISearchable

Last updated 6 years ago

Comments

Common

(Enter the content of this article below)

Advanced

 
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

Contents
No sections defined
Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  

What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out