Created
May 4, 2023 13:15
-
-
Save hishaamn/f62d3ea76af65f2c46f7fdd292278aca to your computer and use it in GitHub Desktop.
Extension of the Content Editor Form to add event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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