Skip to content

Instantly share code, notes, and snippets.

View kamsar's full-sized avatar
:shipit:
127.0.0.1

Kam Figy kamsar

:shipit:
127.0.0.1
View GitHub Profile
@kamsar
kamsar / DimensionStrippingGetImageFieldValue.cs
Created July 23, 2014 06:00
Sitecore 7,2-compatible rich text image dimension stripper
// Strips width and height attributes from Sitecore field rendered images without messing with the
// resizer's width and height attributes (as opposed to maxwidth/maxheight)
public class DimensionStrippingGetImageFieldValue : GetImageFieldValue
{
protected override Sitecore.Xml.Xsl.ImageRenderer CreateRenderer()
{
return new ImageRenderer();
}
private class ImageRenderer : Sitecore.Xml.Xsl.ImageRenderer
@kamsar
kamsar / GetFromSynthesis.cs
Created November 7, 2014 17:25
Synthesis Sitecore MVC prototype
using Synthesis.Mvc.Pipelines.GetRenderer;
using Sitecore.Mvc.Pipelines.Response.GetModel;
using Sitecore.Mvc.Presentation;
using Synthesis;
namespace Synthesis.Mvc.Pipelines.GetModel
{
public class GetFromSynthesis : GetModelProcessor
{
@kamsar
kamsar / PageEditor.js
Created January 14, 2015 14:25
Fix Ctrl-S in Sitecore 8 RTM Experience Editor
// Open the Website\sitecore\shell\Applications\Page Modes\PageEditor.js file
// Search for "e.keyCode == 83"
// Make the statement look like this:
//Ctrl+S
if (e.keyCode == 83 && e.ctrlKey) {
e.preventDefault();
this.onSaving();//fix for 428752
this.save();
return;
@kamsar
kamsar / SwitchMasterToWeb.config
Last active April 9, 2017 20:35
Sitecore 8 Patched SwitchMasterToWeb.config
<?xml version="1.0" encoding="utf-8" ?>
<!--
Purpose: This include file simplifies the setup of Sitecore CD instances by removing any references to the Master database from Sitecore configuration files.
This include file should be used only on CD servers.
Important: Include files are applied in alphabetical order. Therefore this include file cannot remove any references to the Master database
that are defined in include files that are applied later. In this situation, you must rename this include file so that it is applied after
any other include files that contain references to "master" database.
#
# MongoDB (as a windows service)
#
$mongoDbPath = "$env:SystemDrive\MongoDB"
$mongoDbConfigPath = "$mongoDbPath\mongod.cfg"
$url = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-3.2.7.zip"
$zipFile = "$mongoDbPath\mongo.zip"
$unzippedFolderContent ="$mongoDbPath\mongodb-win32-x86_64-2008plus-3.2.7"
if ((Test-Path -path $mongoDbPath) -eq $false)
@kamsar
kamsar / ee.html
Created February 17, 2015 15:37
Open field editor in Sitecore Experience Editor
<a href="javascript:Sitecore.PageModes.PageEditor.postRequest('webedit:fieldeditor(command={11111111-1111-1111-1111-111111111111},fields=Field Name 1|Field Name 2,id={item-id-to-edit-with-braces})')">Edit fields</a>
@kamsar
kamsar / MultiRootTreeList.cs
Created May 5, 2015 23:43
Multi-Root TreeList
using System;
using System.Linq;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
using Sitecore.Shell.Applications.ContentEditor;
using Sitecore.Text;
using Sitecore.Web;
using Sitecore.Web.UI.HtmlControls;
using Sitecore.Web.UI.WebControls;
@kamsar
kamsar / sample.yml
Created June 2, 2015 02:56
YAML Serialization
ID 32A37307-0A19-4995-949C-17D843D799D8
PID 1168BC6E-35CB-41DD-9256-B828550E9E50
TID FE8D0E16-455D-441E-A525-58B2128F6EFA
PATH /sitecore/content/test
---
DatabaseName: master
SharedFields:
- Id: a4f985d9-98b3-4b52-aaaf-4344f6e747c6
NameHint: __Workflow
Value: '{7121FA3D-B469-4412-A170-53A5D94A80E4}'
@kamsar
kamsar / Benchmark.cs
Created June 11, 2015 13:30
Synthesis mapping performance
var items = Sitecore.Context.Database.GetRootItem().Axes.GetDescendants();
Response.Write("<h1>{0} Items</h1>".FormatWith(items.Length));
var sw = new Stopwatch();
sw.Start();
var displayNamesScapi = items.Select(item => item[FieldIDs.DisplayName]).ToList();
sw.Stop();
@kamsar
kamsar / Performance.Dev.config
Last active August 17, 2021 16:04
SItecore 8.0/8.1/8.2 Performance Config
<!--
A set of performance optimizations for development that vastly increase application startup time.
Should not be used in production, as they largely disable forensic diagnostics that you'd want there over fast startup time after a compile.
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />