Skip to content

Instantly share code, notes, and snippets.

@GuitarRich
GuitarRich / headlesssxa.module.json
Created March 14, 2023 18:35
Example Sitecore Content Serialization module for Headless SXA.
{
"$schema": "../../.sitecore/schemas/ModuleFile.schema.json",
"tags": [ "platform" ],
"namespace": "Project.HeadlessSXAExample",
"items": {
"includes": [
{
"name": "ProjectTemplates",
"path": "/sitecore/templates/Project/<TENENT_NAME>",
"allowedPushOperations": "CreateUpdateAndDelete"
@GuitarRich
GuitarRich / GenerateTemplatesStruct.ps1
Created November 15, 2018 19:06
Generates a Templates.cs struct for a given Sitecore Template
function Get-CleanName()
{
param (
[string] $Name
)
return $Name.Replace(" ", "")
}
$templateItem = Get-Item .
public static class SearchExtensions
{
public static IQueryable<TSource> ContainsOr<TSource, TKey>(this IQueryable<TSource> queryable, Expression<Func<TSource, TKey>> keySelector, IEnumerable values) where TKey : IEnumerable
{
return Contains(queryable, keySelector, values, true);
}
public static IQueryable<TSource> ContainsAnd<TSource, TKey>(this IQueryable<TSource> queryable, Expression<Func<TSource, TKey>> keySelector, IEnumerable values) where TKey : IEnumerable
{
return Contains(queryable, keySelector, values, false);
@GuitarRich
GuitarRich / JsxResult.cs
Created July 22, 2016 18:56
Sitecore and React Examples
namespace Sitecore.Foundation.React.Mvc
{
using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Web.Mvc;
public class JsxResult : ViewResult
{
<#@ Assembly Name="$(SolutionDir)\packages\Fortis.3.5.5.2\lib\net45\Fortis.dll" #>
<#@ Assembly Name="$(SolutionDir)\..\Libraries\Sitecore.Kernel.dll" #>
<#@ assembly name="$(ProjectDir)$(OutDir)Transitus.Rainbow.dll" #>
@GuitarRich
GuitarRich / Benchmark.cs
Last active August 29, 2015 14:22
Fortis Object Mapper Performance
var items = Sitecore.Context.Database.GetItem(new ID("{1FBCAB2D-8444-43FB-916C-951AE3FA244E}")).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();