Hello,
In order to achieve this, you will need to use the
CustomDataHandler class and in particular, its
OnGetContent method. In general, the custom handler (CustomDataHandler, CustomTreeNodeHandler etc.) gives you ability to execute custom code when some
CMS event occurs. The events of
CustomDataHandler are applied to all data items that are stored to the database and the OnGetContent is a method used by smart search. It's called every time the document (or custom table, forum, user) is indexed.
The first parameter usually contains
TreeNode object (or CustomTableItem, ForumPostInfo, UserInfo object) and the second parameter contains text that gets indexed by Lucene.NET search ungine used in Kentico CMS smart search module. You can use this method to modify the text, e.g. add content of the
industryName field from the custom table to it depending on the ItemID of the current
TreeNode object that represents the current document.
public override string OnGetContent(object obj, string content)
{
CMS.TreeEngine.TreeNode node = obj as CMS.TreeEngine.TreeNode;
if (node != null)
{
int ItemID = CMS.GlobalHelper.ValidationHelper.GetInteger(node.GetValue("ItemID"), 0);
if (ItemID != 0)
{
string industryName;
// get the value of industryName based on the ItemID
content = content + " " + industryName;
}
}
}
If you want more information about the
CustomDataHandler class and how to add it to your project, please visit following links:
Event handling overview,
Data handlerAPI related to custom tables is available here:
API - getting custom tables,
Kentico CMS APIBest reagards,
Michal Legen