LibrarySites.Banner

All About Events in the Sitecore ASP.NET CMS

This blog post contains or links to everything I could find about the event management system in the Sitecore ASP.NET CMS.

This will be a relatively short post, as the Using Events entry on the Sitecore Developer Network (SDN) provides detailed information about intercepting events. To customize and extend Sitecore, you can define event handlers using the configuration factory, you can subscribe to events dynamically and you can raise custom events. For more information about the configuration factory, see my blog post The Sitecore ASPNET CMS Configuration Factory.

For information about choosing between events, pipelines, the rules engine and validation, see my blog post Intercepting Item Updates with Sitecore.

Event handlers should behave correctly even if Sitecore fire the same event more than once when you expect a single occurrence.

The item:added and item:created events seem similar, but Sitecore only fires item:added when a user creates an item through the UI, but it fires fires item:created when code creates items through APIs. Use item:added if you only need to trap manual item additions. Sitecore fires item:saved in either case, so I generally use item:saved, even though it gets called more frequently and is therefore less efficient. Using item:saved lets me put all the logic in a single handler, which fires after create, update, rename, move and potentially other events.

For an example that uses events to move items, which shows how to use the event systems to update items dynamically, see my blog post Sitecore Shared Source NewsMover Categorizes News by Date. Note how this solution addresses the issue that writing to an event from a write event handler can raise write events, resulting in an infinite event loop.

Sitecore 6.3 introduced the concept of remote events, providing a system event queue separate from each database event queue. For more information about remove events, see the Scaling Guide on SDN.

If you know of additional resources about events with Sitecore, or if you have any questions about event management with Sitecore, please comment on this blog post.

More posts All About the Sitecore ASP.NET CMS