Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeroen Breuer jbreuer

  • Colours
  • Den Bosch
View GitHub Profile
@jbreuer
jbreuer / ProjectIdentityProvider.cs
Last active Jun 22, 2021
Custom identity provider in Sitecore
View ProjectIdentityProvider.cs
public class ProjectIdentityProvider : IdentityProvidersProcessor
{
private readonly IConfigurationRepository configurationRepository;
private readonly IUrlUtils urlUtils;
private readonly ICookieManager cookieManager;
public ProjectIdentityProvider(
IConfigurationRepository configurationRepository,
@jbreuer
jbreuer / HybridPlaceholder.jsx
Last active Jul 22, 2021
Hybrid Placeholder
View HybridPlaceholder.jsx
import React, { useEffect, useState } from 'react';
import { withSitecoreContext, dataApi, Placeholder } from '@sitecore-jss/sitecore-jss-react';
import { dataFetcher } from './dataFetcher';
import config from './temp/config';
const HybridPlaceholder = ({
name,
rendering,
sitecoreContext,
}) => {
@jbreuer
jbreuer / ContentExtensions.cs
Created May 18, 2016
An extension method to convert an IContent to an IPublishedContent.
View ContentExtensions.cs
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ContentExtensions.cs" company="Colours B.V.">
// © Colours B.V. 2015
// </copyright>
// <summary>
// The content extensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Project.Web.Core.Extensions
@jbreuer
jbreuer / gist:e4103c4d731fe3fdb275
Created Jul 16, 2015
Would be cool if this could work for Nested Content
View gist:e4103c4d731fe3fdb275
var items = this.GetPropertyValue<IEnumerable<IPublishedContent>>("sliderNestedContent");
//Slider is a generated model based on a document type.
//Currently x as Slider returns null.
return items.Select(x => x as Slider);
@jbreuer
jbreuer / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jbreuer
jbreuer / gist:0a5996e5e6bf881ce847
Last active Dec 31, 2018
Archetype and Nested Content as Models Builder properties
View gist:0a5996e5e6bf881ce847
[ImplementPropertyType("slider")]
public IEnumerable<HomeSlider> Slider
{
get
{
var archetypeModel = this.GetPropertyValue<ArchetypeModel>("slider");
return archetypeModel.Select(x =>
{
return new HomeSlider()
{
@jbreuer
jbreuer / gist:a396f1e4504e181e1c8a
Created Nov 20, 2014
Strongly typed querying in Umbraco
View gist:a396f1e4504e181e1c8a
/// <summary>
/// Return the all the data required for filtering and displaying object types.
/// </summary>
/// <returns></returns>
public static IEnumerable<ObjectTypeItem> GetObjectTypeItems()
{
//Get the node where all projects and object types are below.
var projectOverview = Umbraco.TypedContent(ConfigurationManager.AppSettings["projectOverviewId"]);
return
@jbreuer
jbreuer / gist:956aeb77c0c679f44cc0
Last active Nov 12, 2018
Get current domain root node in Umbraco content finder
View gist:956aeb77c0c679f44cc0
public class NewsContentFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
if (contentRequest != null && contentRequest.HasDomain)
{
var rootDomainNode = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(contentRequest.Domain.RootNodeId);
}
}
}
@jbreuer
jbreuer / gist:76d802851346b991af26
Created Aug 28, 2014
Nested Archetype. Doesn't seem to work.
View gist:76d802851346b991af26
var archetypeModel = this.GetPropertyValue<ArchetypeModel>("tourLocations");
return archetypeModel.Select(x =>
{
return new TourLocation()
{
Name = x.GetValue<string>("name"),
Translations = x.GetValue<ArchetypeModel>("translations").Select(y =>
{
return new Translation()
{
@jbreuer
jbreuer / GoogleMapsConverter
Created Jul 24, 2014
GoogleMapsConverter for Umbraco 7.1.5 or higher
View GoogleMapsConverter
public class GoogleMapsConverter : PropertyValueConverterBase, IPropertyValueConverterMeta
{
public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
{
if(source != null && !string.IsNullOrWhiteSpace(source.ToString()))
{
var coordinates = source.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (coordinates.Length == 3)
{
return new GoogleMaps