Skip to content

Instantly share code, notes, and snippets.

SiteContext targetSiteContext = SiteContext.GetSite(sitename);
using (var context = new SiteContextSwitcher(targetSiteContext))
{
// do something on the new site context
Item myItem = context.Database.GetItem("ID");
}
public static class TemplateItemExtensions
{
public static IEnumerable<TemplateFieldItem> GetFieldsOfSelfAndBaseTemplates(this TemplateItem self)
{
var templateFieldItems = new Dictionary<ID, TemplateFieldItem>();
GetAllFieldsForTemplate(self, templateFieldItems);
return templateFieldItems.Values;
}
Template template = TemplateManager.GetTemplate(new ID(""), Sitecore.Context.Database);
TemplateField[] allFields = template.GetFields(true);
using Sitecore.Form.Core.Attributes;
using System;
using System.ComponentModel;
using System.Web.UI;
namespace CustomWFFM.CustomFieldTypes
{
[ValidationProperty("Text")]
public class SingleLineTextWithPlaceholderField : Sitecore.Form.Web.UI.Controls.SingleLineText
{
using System.ComponentModel;
using Sitecore.Data.Items;
namespace CustomWFFM.CustomFieldTypes.Mvc
{
public class SingleLineTextWithPlaceholderField : Sitecore.Forms.Mvc.Models.Fields.SingleLineTextField
{
[DefaultValue("")]
public string PlaceholderText { get; set; }
@using Sitecore.Mvc
@model CustomWFFM.CustomFieldTypes.Mvc.SingleLineTextWithPlaceholderField
@if (!Model.Visible)
{
return;
}
<div class="@Model.CssClass field-border">
using System.Linq;
using Sitecore.Configuration;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.ExpandInitialFieldValue;
namespace CustomExpandTokenProcessors.Pipelines
{
public class NextSortOrderReplacer : ExpandInitialFieldValueProcessor
{
using Sitecore.Diagnostics;
using Sitecore.Pipelines.ExpandInitialFieldValue;
namespace CustomExpandTokenProcessors.Pipelines
{
public class CustomTokenReplacer : ExpandInitialFieldValueProcessor
{
private const string Token = "$customtoken";
public override void Process(ExpandInitialFieldValueArgs args)
using System;
using System.Text.RegularExpressions;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.ExpandInitialFieldValue;
namespace CustomExpandTokenProcessors.Pipelines
{
public class QueryTokenReplacer : ExpandInitialFieldValueProcessor
{
// Decompiled with JetBrains decompiler
// Type: Sitecore.Sites.SiteContext
// Assembly: Sitecore.Kernel, Version=8.1.0.0, Culture=neutral, PublicKeyToken=null
//
// NOTE: This is not the complete implementation, only fractions of the important parts related
// to getting cookie by key from the site-context.
//
namespace Sitecore.Sites
{