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 / SubcontentField.cs
Last active September 10, 2018 07:53
Subcontent Computed Field
using System.Collections.Generic;
using System.Linq;
using Blade.Utility;
using Sitecore;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.Layouts;
@kamsar
kamsar / SwitchMasterToWeb.config
Created December 5, 2016 22:17
Sitecore 8.2 Update 1 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. The include files in root folder are applied before the include files in the subdirectories.
The subdirectories 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
@kamsar
kamsar / SampleController.cs
Created May 3, 2014 02:56
Web API attribute routing sample controller
using System.Collections.Generic;
using System.Web.Http;
namespace Foo.Web.Sites.ExampleSite.Shared.Data
{
// for more on Attribute Routing (used in this sample to create routes), see http://blogs.msdn.com/b/webdev/archive/2013/10/17/attribute-routing-in-asp-net-mvc-5.aspx
// the RoutePrefix is the base path to the API controller
[RoutePrefix("ExampleSite/api/Sample")]
// this defines how to perform default route lookups on methods (e.g. this routes the action to a method of the same name like asp.net MVC, and sets Get() to the default action)
@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 / BenchmarkHabitatBuild.cmd
Last active January 4, 2018 18:43
Benchmark script to test actions on Sitecore instances
@echo off
"%PROGRAMFILES(x86)%\MSBuild\14.0\bin\msbuild.exe" "Habitat.sln" /p:Configuration=Debug /m /t:Clean /nr:false
"%PROGRAMFILES(x86)%\MSBuild\14.0\bin\msbuild.exe" "Habitat.sln" /p:Configuration=Debug /m /t:Build /nr:false
echo Take note of the timing above, this is the CLEAN BUILD time
pause
"%PROGRAMFILES(x86)%\MSBuild\14.0\bin\msbuild.exe" "Habitat.sln" /p:Configuration=Debug /m /t:Build /nr:false
@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.
@kamsar
kamsar / SwitchMasterToWeb.config
Created October 29, 2015 19:56
Sitecore 8.1 SwitchMasterToWeb Patches
<?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. The include files in root folder are applied before the include files in the subdirectories.
The subdirectories 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
@kamsar
kamsar / WebApiConfig.cs
Created May 3, 2014 02:58
Sitecore Web API registration
using System.Net.Http.Formatting;
using System.Web.Http;
using Foo.Web;
// automatically exectute this class' Start() method right after Application_Start (without needing to change global.asax)
[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(WebApiConfig), "Start")]
namespace Foo.Web
{
public static class WebApiConfig
@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>
@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)
{
}
}