Skip to content

Instantly share code, notes, and snippets.

View merkle-sitecore-gists's full-sized avatar

Merkle DACH merkle-sitecore-gists

View GitHub Profile
@merkle-sitecore-gists
merkle-sitecore-gists / Export-SitecoreTree.ps1
Last active July 21, 2020 14:39
Export Sitecore item data in json to compare it with your preferred comparison tool
############################################################
# This Script can be used for export Sitecore Item tree data
# This can be used for comparison scenarios like
# 1. Compare content of different databases eg: "master and web"
# 2. Compare content between environments eg: "local, dev, staging, prod"
# 3. Versions or languages
# Benefints: only export field you want to compare/inspect (less noise, like update fields and so on)
# Note: the scripts only deliverys the export. Comparision have to be done with a different tool (winmerge, baretail, kdiff etc.
# Preconditions: Powerhshell Sitecore Extensions installed
############################################################
using System.Collections.Generic;
using System.Linq;
using Sitecore.Configuration;
using Sitecore.Data.Managers;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
using Sitecore.Pipelines.HttpRequest;
using Sitecore.Web;
using Sitecore.Sites;
<link rel="alternate" hreflang="x-default" href="https://www.mysite.com/" />
<link rel="alternate" hreflang="de" href="https://www.mysite.com/de-de" />
<link rel="alternate" hreflang="en" href="https://www.mysite.com/en-de" />
<link rel="alternate" hreflang="es" href="https://www.mysite.com/es-es" />
<link rel="alternate" hreflang="fr" href="https://www.mysite.com/fr-fr" />
<link rel="alternate" hreflang="zh" href="https://www.mysite.com/zh-cn" />
<link rel="alternate" hreflang="zh-CN" href="https://www.mysite.com/zh-cn" />
<link rel="alternate" hreflang="en-US" href="https://www.mysite.com/en-us" />
<link rel="alternate" hreflang="de-DE" href="https://www.mysite.com/de-de" />
<link rel="alternate" hreflang="en-DE" href="https://www.mysite.com/en-de" />
using System;
using System.Net;
using System.Text.RegularExpressions;
using Sitecore.Data.Items;
using Sitecore.Rules;
using Sitecore.Rules.Actions;
namespace TAC.Internet.Web.CMS.Client.Rules.ItemSaved
{
   public class CopyFieldToField<T> : RuleAction<T> where T : RuleContext
<div class="molecule-parent">
<p>Parent</p>
<div class="atom-subcomponent parent-default subcomponent-overwrite">
<div>Subcomponent</div>
</div>
</div>
<div class="molecule-parent">
<p>Parent</p>
<div class="atom-subcomponent subcomponent-overwrite">
<div>Subcomponent</div>
</div>
</div>
<div class="molecule-parent">
<p>Parent</p>
<div class="atom-subcomponent subcomponent-default">
<div>Subcomponent</div>
</div>
</div>
<div class="atom-subcomponent{{#if modifier}} {{modifier}}{{/if}}{{#if decorator}} {{decorator}}{{/if}}">
<div>{{content}}</div>
</div>
<div class="molecule-parent{{#if modifier}} {{modifier}}{{/if}}">
<p>{{text}}</p>
{{ pattern name="subcomponent" modifier=false decorator="subcomponent-overwrite" }}
</div>
// Model for parent.hbs
public class ParentComponentModel {
public string Text { get; set; }
public string Modifier { get; set; } = "parent-default";
public SubcomponentModel Subcomponent { get; set; }
}
// Model for subcomponent.hbs
public class SubcomponentModel {
public string Content { get; set; }