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;
}
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
{
Template template = TemplateManager.GetTemplate(new ID(""), Sitecore.Context.Database);
TemplateField[] allFields = template.GetFields(true);
using System;
using System.Text.RegularExpressions;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.ExpandInitialFieldValue;
namespace CustomExpandTokenProcessors.Pipelines
{
public class QueryTokenReplacer : ExpandInitialFieldValueProcessor
{
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
{
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<expandInitialFieldValue>
<processor type="CustomExpandTokenProcessors.Pipelines.MyCustomTokenReplacer, CustomExpandTokenProcessors" patch:after="processor[@type='type=Sitecore.Pipelines.ExpandInitialFieldValue.ReplaceVariables, Sitecore.Kernel']"/>
</expandInitialFieldValue>
</pipelines>
</sitecore>
</configuration>
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)