Skip to content

Instantly share code, notes, and snippets.

@jammykam
jammykam / MigrateLayouts.aspx
Created September 1, 2022 13:26
This script migrates the "old" layout format to the new format used in Sitecore 8.2 Update-7 and Sitecore 9 Update-2. Code from: https://sitecore.namics.com/upgrading-to-sitecore-9-0-update-2-and-later-versions-might-change-the-order-of-renderings/ updated to use ID rather than path
<%@ Page Language="C#" AutoEventWireup="true" Debug="true" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="Sitecore" %>
<%@ Import Namespace="Sitecore.Configuration" %>
<%@ Import Namespace="Sitecore.Data" %>
<%@ Import Namespace="Sitecore.Data.Fields" %>
<%@ Import Namespace="Sitecore.Data.Items" %>
<%@ Import Namespace="Sitecore.Globalization" %>
<%@ Import Namespace="Sitecore.Layouts" %>
@jammykam
jammykam / nuget.config
Created February 15, 2022 00:38
Sitecore nuget.config sources
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Used to specify the default Sources for list, install and update.
-->
<packageSources>
<clear />
<add key="Nuget" value="https://api.nuget.org/v3/index.json" />
<add key="Sitecore Public Feed" value="https://sitecore.myget.org/F/sc-packages/api/v3/index.json" />
<add key="Sitecore Commerce Public Feed" value="https://sitecore.myget.org/F/sc-commerce-packages/api/v3/index.json" />
@jammykam
jammykam / protobuf.filepath.config
Last active February 17, 2022 19:36
Patch the Sitecore Protobuf Filepath locations to look at module items (useful for Sitecore 10.1)
<?xml version="1.0" encoding="utf-8" ?>
<!--
Purpose: Adds in an additional location to load IAR files from
This config can be removed if the project is upgraded to 10.2+ since the path is set ootb
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<databases>
<database id="master" role:require="Standalone or ContentManagement">
<dataProviders>
@jammykam
jammykam / Preview.Database.config
Created November 5, 2021 04:02
Sitecore 10.1+ additional Preview database config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/">
<sitecore role:require="ContentManagement">
<eventing>
<eventQueueProvider>
<eventQueue name="web_preview" patch:after="eventQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
<param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
<param hint="" ref="PropertyStoreProvider/store[@name='$(name)']" />
</eventQueue>
</eventQueueProvider>
@jammykam
jammykam / settings.json
Last active January 8, 2021 01:57
Konabos Microsoft Terminal Settings
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
@jammykam
jammykam / EditHtml.cs
Last active March 10, 2018 00:02
Extension to post by @rpeplau to resolve RTE tokens in Experience Editor mode for site specific purposes http://blog.peplau.com.br/en_US/site-specific-richtext-editor-profiles-custom-source-in-native-richtext-fields/
using Sitecore;
using Sitecore.Data.Fields;
using Sitecore.Diagnostics;
using Sitecore.ExperienceEditor.Utils;
using Sitecore.Globalization;
using Sitecore.Shell.Applications.ContentEditor.RichTextEditor;
using Sitecore.Web.UI.Sheer;
namespace Konabos.RteSources.Commands
{
@jammykam
jammykam / Attach.ImageCheckSize.cs
Last active November 27, 2019 13:26
Restrict Media Upload in Experience Editor and Content Editor in Sitecore 8.2 update-5. See following for further reference: https://stackoverflow.com/a/27956033/661447 | https://sitecore.stackexchange.com/q/9009/135 | https://sitecore.stackexchange.com/q/9060/135
using Sitecore;
using Sitecore.Exceptions;
using Sitecore.Pipelines.Attach;
namespace MyProject.MediaUpload.Pipelines.Attach
{
public class ImageCheckSize
{
public void Process(AttachArgs args)
{
Use master
GO
sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
sp_configure 'contained database authentication', 1
GO
RECONFIGURE WITH OVERRIDE
GO
@jammykam
jammykam / HiddenToken.cs
Last active October 8, 2017 19:21
Sitecore WFFM Hidden Token Field
using System.ComponentModel;
using System.Web.UI;
using Sitecore.Form.Core.Attributes;
using Sitecore.Form.Core.Visual;
using Sitecore.Form.Web.UI.Controls;
namespace MyProject.CMS.Custom.WFFM.Fields.HiddenTokenField
{
public class HiddenToken : InputControl
{

Create WFFM field in Sitecore under /sitecore/system/Modules/Web Forms for Marketers/Settings/Field Types. For example:

  • Item Path: /sitecore/system/Modules/Web Forms for Marketers/Settings/Field Types/Custom/Label
  • Template: /sitecore/templates/Web Forms for Marketers/Field Type
  • Assembly: MyProject.CMS.Custom
  • Class: MyProject.CMS.Custom.WFFM.Fields.Label
  • MVC Type: MyProject.CMS.Custom.WFFM.Fields.LabelField, MyProject.CMS.Custom