Skip to content

Instantly share code, notes, and snippets.

View joostbroekhuizen's full-sized avatar

Joost Broekhuizen joostbroekhuizen

  • We are you
  • Amsterdam Area
  • X @djewst
View GitHub Profile
@joostbroekhuizen
joostbroekhuizen / ErrorsLayoutServiceContextProcessor.cs
Last active January 17, 2020 15:56
Custom Sitecore JSS Layout Processor
/// <summary>
/// Extends the LayoutService context with localized errors.
/// </summary>
public class ErrorsLayoutServiceContextProcessor : JssGetLayoutServiceContextProcessor
{
public ErrorsLayoutServiceContextProcessor(IConfigurationResolver configurationResolver) : base(configurationResolver)
{
}
protected override void DoProcess(GetLayoutServiceContextArgs args, AppConfiguration application)
@joostbroekhuizen
joostbroekhuizen / BaseGraphQLRenderingContentsResolver.cs
Last active January 17, 2020 15:49
Custom Sitecore JSS GraphQL resolver
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using Sitecore.JavaScriptServices.GraphQL.LayoutService;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering.ContentsResolvers;
using Sitecore.Mvc.Presentation;
using System;
namespace Custom.Foundation.Content.JavascriptServices.RenderingContentsResolvers
{
@joostbroekhuizen
joostbroekhuizen / DescendantsRenderingContentsResolver.cs
Created January 17, 2020 15:19
Custom Sitecore JSS Descendants resolver
/// <summary>
/// Builds a tree-like structure of datasource item's descendants
/// </summary>
/// <seealso cref="Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver" />
public class DescendantsRenderingContentsResolver : Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver
{
protected override JObject ProcessItem(Item item, IRenderingConfiguration renderingConfig)
{
var jObject = base.ProcessItem(item, renderingConfig);
@joostbroekhuizen
joostbroekhuizen / RichTextEditorSaveEvent.cs
Created February 28, 2018 10:14
Sitecore richtext field custom save event to clean up HTML
///
/// Don't forget following config file patch for Sitecore:
/// <configuration>
/// <sitecore>
/// <events>
/// <event name="item:saved">
/// <handler type="YourNameSpace.Sitecore.Events.RichTextEditorSaveEvent, YourNameSpace.Sitecore" method="OnItemSaving">
/// <database>master</database>
/// </handler>
/// </event>