Skip to content

Instantly share code, notes, and snippets.

/////// FROM ///////
protected virtual XDocument BuildXmlDocument(IEnumerable<XElement> pages) => new XDocument(new XDeclaration("1.0", "UTF-8", "no"), new object[1]
{
(object) new XElement(SitemapGenerator.ns + "urlset", new object[2]
{
(object) new XAttribute(XNamespace.Xmlns + "xhtml", (object) (XNamespace) "http://www.w3.org/1999/xhtml"),
(object) pages
})
});
$dialogProps = @{
Title = "Version Lister"
Description = "The dialog allows the selection whether to see all versions or only the latest"
Width = 500
Height = 100
OkButtonName = "OK"
CancelButtonName = "Cancel"
Parameters = @(
@{ Name = "onlyLatest"; Value=$true; Title="Show only latest versions"; Editor="checkbox"; }
)
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>