Prev Next |
Instead of various Sitecore V4 handlers (like ItemEventHandler, MediaHandler, Publishing Handler and so on), Sitecore V5 offers unified event model.
Sitecore V5 events also address some of the shortcomings that Sitecore V4 handlers had.
To port your specific handler to Sitecore V5 you need to
- Find a Sitecore V5 event matching the handling type and your goal. Please refer to Using Sitecore Events article for a complete list of exposed events.
- Update your handler signature to match the event system. Parameters available to event handler depend on the actual event.
- Subscribe to the event. Typically this is done in sitecore/events section of web.config file
Example:
Say, you had an Item event handler that replaces all ‘*’ symbols in an Item’s name (taken from Sitecore V4 server events article):
public class CustomItemHandler : IItemEventHandler
{
//Replaces the "*" symbols on gaps
void IItemEventHandler.HandleSaved(IMasterItem itm, NameValueCollection configSettings)
{
string szTitle = itm.GetFieldValue("Title");
itm.GetLatestVersion().SetFieldValue("Title", szTitle.Replace("*"," "));
}
}
and the handler is registered in web.config in the following way:
<eventHandlers>
...
<items>
…
<handler mode="on" assembly="CustomItemHandler" type="CustomItemHandler" CustomNodeTitle="New Item: "/>
</items>
...
</eventHandlers>
Prev Next