User
User

Reputation: 281

Where sitecore event handlers are located

Where can I see the source code of sitecore predefined event handlers(e.g. item deleted event handler, OnPublishEnd and other). I want to change them.

Upvotes: 1

Views: 1336

Answers (1)

user459491
user459491

Reputation:

For exemple when you delete an item from Sitecore interface you have next event:

 <event name="item:deleted">
    <handler type="Sitecore.Links.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />
    <handler type="Sitecore.Tasks.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />
    <handler type="Sitecore.Globalization.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />
    <handler type="Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />
    <handler type="Sitecore.Rules.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />
  </event>

You can decompile Sitecore.Kernel.dll with Reflector or Dot Peek and to see in deep the code.

For "publish:end" you have next code

 <event name="publish:end">
    <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache>
      <sites hint="list">
        <site>website</site>
      </sites>
    </handler>
  </event>

This lines appear on web.config file. I suggest you to use patching, to create new config files for custom events. A good start how to use config files is this article.

If you created a class and method for item deleted for exemple on config files under event "item:deleted" you will have :

<handler type="YourNamespace.YourClassName, YourAssembly" method="YourMethodName" /> 

Information about using events and how to do you find here.

Upvotes: 6

Related Questions