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 / zContentSearch.config
Created May 15, 2014 03:32
SubcontentField registration patch
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<defaultLuceneIndexConfiguration>
<fields hint="raw:AddComputedIndexField">
<!-- indexes subcontent contents into parent's _content field in the index (for better site search) -->
<field fieldName="_content" type="Foo.ContentSearch.ComputedFields.SubcontentField, Foo" />
</fields>
</defaultLuceneIndexConfiguration>
@kamsar
kamsar / AutoEncryptConnectionStrings.cs
Created July 16, 2014 00:55
Automatic web.config encryption example
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using Foo.Web;
[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(AutoEncryptConnectionStrings), "AutoEncrypt")]
namespace Foo.Web
{
public class AutoEncryptConnectionStrings
@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 / 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 / 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 / forms.config
Created October 9, 2013 15:49
forms.config modification for WFM connection string provider
<formsDataProvider type="My.Namespace.SqlServerWfmDataProvider, My.Assembly">
<param desc="connection string name">forms</param>
</formsDataProvider>
@kamsar
kamsar / SqlServerWfmDataProvider.cs
Created October 9, 2013 15:46
WFM Connection String Provider
/// <summary>
/// Extends the standard WFM data provider to use a regular .NET connection string name instead of a bare connection string (such that we can store all connection strings in one file)
/// </summary>
public class SqlServerWfmDataProvider : WFMDataProvider
{
public SqlServerWfmDataProvider(string connectionStringName) : base(ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString)
{
}
}
@kamsar
kamsar / Serialization Config
Last active January 4, 2016 20:09
Unicorn 2 Multiple Serialization Roots and Presets
<serialization>
<default>
<include database="master" path="/sitecore/templates"/>
<include database="core" path="/sitecore">
<exclude path="/sitecore/content/Home" />
</include>
</default>
<templates>
<include database="master" path="/sitecore/templates"/>
</templates>