Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Golden BenGGolden

View GitHub Profile
@BenGGolden
BenGGolden / RegisterGoalAction.cs
Created Nov 27, 2016
Sitecore rule engine action to register a goal
View RegisterGoalAction.cs
public class RegisterGoalAction<T> : RuleAction<T> where T : RuleContext
{
public ID GoalId { get; set; }
public override void Apply(T ruleContext)
{
if (!Tracker.IsActive || Tracker.Current.CurrentPage == null) return;
var goal = (PageEventItem)Context.Database.GetItem(GoalId);
if (goal != null)
{
@BenGGolden
BenGGolden / IsInEngagementStateCondition.cs
Created Nov 29, 2016
Sitecore rule engine condition to determine if the current user is in a particular engagement plan state
View IsInEngagementStateCondition.cs
public class IsInEngagementStateCondition<T> : WhenCondition<T> where T : RuleContext
{
public ID StateId { get; set; }
protected override bool Execute(T ruleContext)
{
var automationStateManager = Tracker.Current.Session.CreateAutomationStateManager();
return automationStateManager.IsInEngagementState(StateId);
}
}
View SetPasswordSaveAction.cs
public class SetPasswordSaveAction : UserBaseAction
{
private ID _formId;
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null,
params object[] data)
{
_formId = formId;
var password = adaptedFields.GetEntry(PasswordField, "Password")?.Value ?? string.Empty;
var userName = Tracker.Current?.Session.Contact.Identifiers.Identifier;
var user = Membership.GetUser(userName);
View ReindexTree.ps1
$item = Get-Item .
$options = @{}
[Sitecore.ContentSearch.ContentSearchManager]::Indexes | Foreach-Object { $options.Add($_.Name, $_.Name) }
$props = @{
Parameters = @(
@{Name="indexName"; Title="Choose an index"; Options=$options; Tooltip="Choose one."}
)
Title = "Index selector"
Description = "Choose an index."
Width = 300
@BenGGolden
BenGGolden / Minimal-CommerceServer.Core.config.xml
Last active Jul 6, 2017
Minimal CommerceServer.Core.config
View Minimal-CommerceServer.Core.config.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<CommerceServer>
<application siteName="MyStorefrontSite" />
<catalog />
<profiles />
</CommerceServer>
</configuration>
View FluentTagBuilder.cs
public class FluentTagBuilder
{
public TagBuilder InnerBuilder { get; private set; }
public FluentTagBuilder(string tagName)
{
InnerBuilder = new TagBuilder(tagName);
}
public FluentTagBuilder AddCssClass(string cssClass)
View DynamicPlaceholdersWithoutFluentTagBuilder.cshtml
@* Using with a basic TagBuilder *@
@{
var colDiv = new TagBuilder("div");
colDiv.AddCssClass("col-sm-4");
colDiv.GenerateId("featureCol");
}
<div>
@Html.Sitecore().DynamicPlaceholder("feature", colDiv, 3, 3)
</div>
View FluentTagBuilderHelperExtensions.cs
public static class FluentTagBuilderHelperExtensions
{
public static FluentTagBuilder Tag(this HtmlHelper helper, string tagName)
{
return new FluentTagBuilder(tagName);
}
public static HtmlString DynamicPlaceholder(this SitecoreHelper sitecoreHelper, string placeholderName,
FluentTagBuilder chrome, int count = 1, int maxCount = 0, int seed = 0)
{
View DynamicPlaceholderWithFluentTagBuilder.cshtml
@* Using with a basic TagBuilder *@
<div>
@Html.Sitecore().DynamicPlaceholder("feature",
Html.Tag("div")
.AddCssClass("col-sm-4")
.GenerateId("featureCol"),
3, 3)
</div>
@* Using with a Func<DynamicPlaceholderRenderContext, TagBuilder> *@
View (SIFLess Uninstall for SXC 9)
An extension for the SIFLess uninstall scripts to include SXC 9 components.