How to add a delete event handler for Content > Images

Posted by marcoc22 on 29-Jan-2020 21:28

I am trying to add a new delete event handler when a user removes an image or a library from the Content > Images section. I've already added an event handler to the Global.asax.cs file when Dynamic Content is deleted and it works but I have a question, is the delete images or libraries event handler supported in Sitefinity 12.2?

All Replies

Posted by jread on 31-Jan-2020 18:01

The IDataEvent system still exists in v12.2, here is the documentation:

[View:https://www.progress.com/documentation/sitefinity-cms/for-developers-idataevent:550:50]

Global.asax

using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Data.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
        }

        private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
        {
            EventHub.Subscribe<IDataEvent>(evt => DataEventHandler(evt));
        }

        public void DataEventHandler(IDataEvent eventInfo)
        {
            var action = eventInfo.Action;
            var contentType = eventInfo.ItemType;
            var itemId = eventInfo.ItemId;
            var providerName = eventInfo.ProviderName;

            var manager = ManagerBase.GetMappedManager(contentType, providerName);
            var item = manager.GetItemOrDefault(contentType, itemId);
        }
    }
}

Posted by marcoc22 on 31-Jan-2020 18:13

Thank you!

This thread is closed