Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created May 4, 2023 13:15
Show Gist options
  • Select an option

  • Save hishaamn/f62d3ea76af65f2c46f7fdd292278aca to your computer and use it in GitHub Desktop.

Select an option

Save hishaamn/f62d3ea76af65f2c46f7fdd292278aca to your computer and use it in GitHub Desktop.
Extension of the Content Editor Form to add event
using Sitecore.Data.Events;
using Sitecore.Events;
using Sitecore.Experiment.Notification.Models;
using Sitecore.Shell.Applications.ContentManager;
using Sitecore.Web.UI.Sheer;
using System;
public class ContentEditorExtension : ContentEditorForm
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var site = Client.Site;
site.Notifications.ItemSaved += new ItemSavedDelegate(this.CmsNotification);
}
private void CmsNotification(object sender, ItemSavedEventArgs args)
{
var model = new NotifierArgs
{
EventName = "item:save"
};
Event.RaiseEvent("cms:notify", model);
}
public override void HandleMessage(Message message)
{
base.HandleMessage(message);
var model = new NotifierArgs
{
EventName = message.Arguments["eventName"]
};
switch (message.Name)
{
case "cms:notification":
{
Event.RaiseEvent("cms:notify", model);
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment