Skip to content

Instantly share code, notes, and snippets.

public class ShellDefaultPageExtension : Sitecore.Shell.DefaultPage
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
var control = this.Controls[0];
var page = control.Page;
@hishaamn
hishaamn / CmsNotificationManager.cs
Created May 18, 2023 09:31
The initialization and event handler
public class CmsNotificationManager
{
private static Dictionary<string, string> EventMessages;
public static void Initialize()
{
EventMessages = new Dictionary<string, string>();
Database database = Factory.GetDatabase("master");
@hishaamn
hishaamn / InitializeCmsNotification.cs
Last active May 18, 2023 09:28
A wrapper for the initialization
public class InitializeCmsNotification
{
public void Process(PipelineArgs args) => CmsNotificationManager.Initialize();
}
@hishaamn
hishaamn / PackageInstallationEvent.cs
Created May 4, 2023 17:54
Eventhandler to trigger notification after installation
using Sitecore.Events;
using Sitecore.Install.Events;
using System;
public class PackageInstallationEvent
{
public void OnPackageInstallItemsEndHandler(object sender, EventArgs e)
{
if (e == null)
{
@hishaamn
hishaamn / InitializeCmsNotification.cs
Created May 4, 2023 13:53
Subscribe to the event
public class InitializeCmsNotification
{
public void Process(PipelineArgs args) => CmsNotificationManager.Initialize();
}
@hishaamn
hishaamn / CmsNotificationManager.cs
Created May 4, 2023 13:42
Notification Manager to trigger the toast message
using Sitecore.Events;
using Sitecore.Experiment.Notification.Models;
using Sitecore.Web.UI.Sheer;
using System;
public class CmsNotificationManager
{
private static bool _initialized;
private static readonly object globalLock = new object();
@hishaamn
hishaamn / ContentEditorExtension.cs
Created May 4, 2023 13:15
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)
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore>
<events>
<event name="packageinstall:items:ended">
<handler type="YourNamespace.ItemPackageEvent, YourAssemblyName" method="OnPackageInstallItemsEndHandler" />
</event>
</events>
</sitecore>
</configuration>
public class ItemPackageEvent
{
public void OnPackageInstallItemsEndHandler(object sender, EventArgs e)
{
if (e == null)
{
return;
}
SitecoreEventArgs sitecoreEventArgs = e as SitecoreEventArgs;
public class SxaDataView : BucketDataView
{
protected override void GetChildItems(ItemCollection items, Item item)
{
if (ItemIDs.MediaLibraryRoot == item.ID)
{
using (new LanguageSwitcher(item.Language))
{
Item rootItem = ServiceLocator.ServiceProvider.GetService<ISiteMediaRootProvider>().GetRootItem(item.Database);
if (rootItem != null)