Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Web.UI.HtmlControls.Data;
namespace MyProject.CMS.Custom.Controls
{
public class QueryableTreelist : Sitecore.Shell.Applications.ContentEditor.TreeList
@jammykam
jammykam / CreateUsers.ps1
Last active April 4, 2022 18:22
Create Users and Add to specified roles from CSV file using Sitecore PowerShell Extensions
$VerbosePreference = "Continue"
$newUsersFile = Receive-File -Path "C:\temp\upload" -CancelButtonName "No, I will do it using MS Excel instead"
$newUsers = Import-Csv -Path $newUsersFile
foreach($user in $newUsers) {
Write-Verbose "Creating User: $($user.Username)"
New-User -Identity $($user.Username) -Enabled -Password $($user.Password) -Email $($user.Email) -FullName "$($user.Name)"
$($user.Roles).Split(",") | ForEach {
@jammykam
jammykam / MediaRequestHandler.cs
Last active March 5, 2024 17:11
Custom Sitecore Media Request handler to deal with media items with the same name but different extensions. If the media with matching extension is not found then the default Sitecore behaviour is used. This is directly inspired by the post by Martin Davies: http://sitecoreskills.blogspot.co.uk/2014/01/handling-duplicate-media-paths-in.html
using System.Web;
using Sitecore.Diagnostics;
using Sitecore.Resources.Media;
using System;
using System.Linq;
using Sitecore.Data.Items;
using Sitecore.IO;
namespace MyProject.Custom.Media
{
@jammykam
jammykam / ConfigReader.cs
Last active October 20, 2016 12:28
Custom Sitecore ConfigReader to allow setting custom include folder locations
using System.Configuration;
using System.Xml;
using Sitecore;
using Sitecore.Configuration;
using Sitecore.Diagnostics;
namespace MyProject.Custom
{
class ConfigReader : Sitecore.Configuration.ConfigReader
{
@jammykam
jammykam / Generate Anti-Update Rollback.ps1
Created January 24, 2017 09:39
Sitecore PowerShell script to generate an anti-update package as a TDS Post Deploy Script - http://wp.me/p2SmN4-fh
$tempFolder = [Sitecore.Update.Utils.FileUtils]::InstallationHistoryRoot
$historyFolder = [Sitecore.MainUtil]::MapPath($tempFolder)
#get the latest update folder
$latestUpdate = Get-ChildItem -Path $historyFolder | Sort-Object LastAccessTime -Descending | Select-Object -First 1
Write-Host $latestUpdate.FullName
[Sitecore.Update.Engine.PackageGenerator]::ConvertRollbackPackage( `
$latestUpdate.FullName + "\rollbackPackage.rlb", `
$latestUpdate.FullName + "\rollbackPackage.update")
@jammykam
jammykam / TDS Post-Deploy Anti-Update Rollback Package.cs
Created January 24, 2017 09:41
TDS Post-Deploy Step to generate anti-update rollback package - http://wp.me/p2SmN4-fh
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor.Contracts;
using Sitecore.Diagnostics;
namespace ForwardSlash.TDS.PostDeploy
{
[Description("Generate anti-update rollback package for latest deployment.")]
using Sitecore;
using Sitecore.Diagnostics;
using Sitecore.Resources;
using Sitecore.Web.UI;
using Telerik.Web.UI;
using Sitecore.Data.Items;
namespace RTEDropList
{
public class EditorConfiguration : Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration
@jammykam
jammykam / ShowTitleWhenBlank.cs
Last active August 15, 2017 20:44
Display Field Title alongside default [No text in field] placeholder when value not set - https://ticdevs.com/developers/presentation/page-editor/fixing-blank-fields - Thanks for @nshack31 for the find
using Sitecore.Pipelines.RenderField;
namespace MyProject.CMS.Custom.Pipelines.RenderField
{
public class ShowTitleWhenBlank
{
public void Process(RenderFieldArgs args)
{
args.RenderParameters["show-title-when-blank"] = "true";
}
@jammykam
jammykam / ExperienceEditorExtension.js
Last active September 8, 2017 21:30
Sitecore 8 Experience Editor – Edit Component Properties causes page to jumps to top
Sitecore.PageModes.ChromeControls = Sitecore.PageModes.ChromeControls.extend({
renderCommandTag: function (command, chrome, isMoreCommand) {
var tag = this.base(command, chrome, isMoreCommand);
if (command.click.indexOf("chrome:") == 0) {
if (command.type == "common" || command.type == "datasourcesmenu" || command.type == "workflow") {
tag.click(function (e) {
e.stop();
});
}
@jammykam
jammykam / GlassEditFrame.cs
Last active September 10, 2017 04:30
Glass Edit Frame - Custom frame wrapper and pop up handler
using System;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using Glass.Mapper.Sc;
namespace MyProject.Custom.HtmlHelpers
{
public static class GlassEditFrameExtensions
{