I am a bit confused by the content of the documentation on Global Events in Kentico 6.0
http://devnet.kentico.com/docs/devguide/event_handlers_overview.htmThe problem that I cannot figure out is how to setup this in my code. I created a class in App_Code but wasnt sure what to name it...if it had to be a specific named thing to be seen. I called it CustomDocumentEventsLoader.cs. I then added my code but VS 2010 was not picking up on the code sense. Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.TreeEngine;
using CMS.GlobalHelper;
using CMS.SettingsProvider;
using CMS.SiteProvider;
[CustomDocumentEvents]
public partial class CMSModuleLoader
{
/// <summary>
/// Attribute class that ensures the loading of custom handlers
/// </summary>
private class CustomDocumentEventsAttribute : CMSLoaderAttribute
{
/// <summary>
/// Called automatically when the application starts
/// </summary>
public override void Init()
{
// Assigns custom handlers to the appropriate events
DocumentEvents.GetContent.After += Document_GetContent_After;
}
private void Document_GetContent_After(object sender, DocumentEventArgs e)
{
TreeNode indexedNode = e.Node;
if (indexedNode != null)
{
// get assigned categories
System.Data.DataSet categories = CMS.SiteProvider.CategoryInfoProvider.GetDocumentCategories(indexedNode..DocumentID, String.Empty, String.Empty);
if (!CMS.GlobalHelper.DataHelper.DataSourceIsEmpty(categories))
{
StringBuilder str = new StringBuilder();
// loop through all categories and add them to the content variable
foreach (System.Data.DataRow category in categories.Tables[0].Rows)
{
str.Append("BSpan" + CMS.GlobalHelper.ValidationHelper.GetString(category["CategoryDisplayName"], ""));
}
e.Content += str.ToString();
}
}
}
}
}