- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
internal void OnItemSaved(object sender, EventArgs args)
{
Sitecore.Diagnostics.Log.Error("OnItemSaved: Fired", new Exception());
var eventArgs = args as Sitecore.Events.SitecoreEventArgs;
Sitecore.Diagnostics.Assert.IsNotNull(eventArgs, "eventArgs");
if (eventArgs == null) return;
var item = eventArgs.Parameters[0] as Sitecore.Data.Items.Item;
var currItem = item;
Sitecore.Diagnostics.Log.Error("OnItemSaved: " + item.Name, new Exception());
TaxonomyBaseItem i = item;
if (currItem != null)
{
try
{
while (item != null && item.TemplateID.ToString() != TopicSectionFrontPageItem.TemplateId)
{
item = item.Parent;
}
if (item == null) return;
Sitecore.Diagnostics.Log.Error("OnItemSaved: " + item.Name, new Exception());
if (!i.TopicTaxonomy.ListItems.Contains(item))
{
Sitecore.Diagnostics.Log.Error("OnItemSaved: Doesn't contain it", new Exception());
Sitecore.Data.Fields.MultilistField mfield = currItem.Fields["Topic Taxonomy"];
if (!mfield.Contains(item.ID.ToString()))
{
using (new Sitecore.SecurityModel.SecurityDisabler())
{
currItem.Editing.BeginEdit();
if (currItem.Fields["Topic Taxonomy"].Value == string.Empty)
{
currItem.Fields["Topic Taxonomy"].Value += item.ID.ToString();
}
else
{
currItem.Fields["Topic Taxonomy"].Value += "|" + item.ID.ToString();
}
Sitecore.Diagnostics.Log.Error("OnItemSaved: " + currItem.Fields["Topic Taxonomy"].Value, new Exception());
currItem.Editing.EndEdit();
}
}
}
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error("OnItemSaved: " + ex.Message, new Exception());
}
}