In my Sitecore 6.1.0 installation, I connected to the "item: added" event by executing my own custom handler as follows (in Web.config):
<event name="item:added">
<handler type="Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel" method="OnItemAdded" />
<handler type="my.project.Classes.OnSaveItemHandler, my.project" method="OnItemAdded" />
</event>
The purpose of this is to force the use of unique names for the elements - in other words, in my OnItemAdded method, I want to search Lucene for any other elements with the same name as the element to be added.
The OnItemAdded method is called each time an element is added to the Sitecore structure. But my problem is that the method is called more than once per element . I saw that it called somewhere between 6 and 26 times for the added element, depending on where in the Sitecore structure I add the element. The body of my OnItemAdded method is empty:
protected void OnItemAdded(object obj, EventArgs args)
{
}
The first time the method is called, when an element is added, the element in the parameter argsis the correct element. If the name of the element theItemName, the FullPath property will look like this:
/sitecore/content/theItemName
Each time, except for the first one, the element looks correct, but the path to the element looks like this:
[orphan]/sitecore/content/theItemName
Why is the [orphan] bit added to the full path? And why is the OnItemAdded method called more than once, although I add only one item?