Skip to content

Instantly share code, notes, and snippets.

@lowedown
lowedown / pollingCacheMiddleware.js
Created November 30, 2022 15:25
JSS Headless Proxy Cache Middleware that polls ContentDelivery for published changes
//cacheMiddleware for Node-level output caching
const mcache = require('memory-cache');
const config = require('./config');
const https = require('https');
const CACHE_TIME_MS = 8 * 60 * 60 * 1000; // 8h
const POLLING_INTERVAL_MS = 5000;
const STATS_LOGGING_INTERVAL_MS = 60000;
// List of urls that will be skipped during caching
@lowedown
lowedown / ContentHubAssetUsageController.cs
Last active November 29, 2021 10:09
API controller that returns references to a ContentHub asset by assetId plus an example widget for use on a contentHub asset details page
using Sitecore.Abstractions;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq;
using Sitecore.ContentSearch.Linq.Utilities;
using Sitecore.Data.Items;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Cors;
@lowedown
lowedown / ContentHubCustomizations.config
Last active November 27, 2021 17:51
Computed index field for Sitecore that indexes ContentHub assetIDs
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/"
xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<contentSearch>
<indexConfigurations>
<defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
<documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
<fields hint="raw:AddComputedIndexField">
@lowedown
lowedown / Headers.aspx
Last active July 14, 2020 13:35
Display all Headers. Do not use in production!
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
@lowedown
lowedown / IdentifyExample.cs
Last active May 2, 2022 22:13
XConnect Contact Repository and service for use in Sitecore components (Tracker must be active)
// Important: Get consent from user first before identifying. Make sure all applicable rules and regulations are followed correctly.
var service = new TrackingService();
service.IdentifyAs("e-mail", "john@doe.com");
service.SetContactName("John", "Doe");
service.SetContactEmail("john@doe.com");
@lowedown
lowedown / CustomManagedSchema.config
Last active April 3, 2020 13:55
Sitecore Customize SOLR Managed Schema
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<customSolrManagedSchema>
<commands applyToIndex="my_custom_index">
<add-or-replace-field-type>
<name>ngram</name>
<class>solr.TextField</class>
@lowedown
lowedown / DatabaseStats.aspx
Created September 20, 2018 14:14
Database statistics
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Configuration" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
@lowedown
lowedown / ReplacePlaceholderRenderingId.ps1
Created August 17, 2018 14:07
String replace in Placeholder Keys
# String Replace inside Placeholder Keys
$oldPlaceholderString = "da653398-c1bc-4587-be48-0ae26b07ba9e"
$newPlaceholderString = "bfd7aec3-8655-4aff-9357-da7529754aad"
$rootItem = "master:/sitecore/content/MyHome/"
$language = "en"
$defaultLayout = Get-LayoutDevice "Default"
# Toggle for whether to update Shared or Final Layout
$useFinalLayout = $False
# If set to true, the script will only list the renderings that need fixing, rather than fixing them.
@lowedown
lowedown / Multisite.ReplaceSiteRootToken.config
Last active November 20, 2017 13:30
Add site root token to lookup field queries
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="MyProject.Multisite.SiteRootTemplateId" value="{161227F1-2BC1-4346-B833-D9DBED0B7104}"/>
<setting name="MyProject.Multisite.SiteRootToken" value="$siteRoot"/>
</settings>
<pipelines>
<getLookupSourceItems>
<processor type="MyProject.Multisite.GetLookupSourceItems.ReplaceSiteRootToken, MyProject"
patch:before="processor[1]" />
#
# Powershell script that reads server role configs from Sitecore's excel file
# and checks a specified directory to ensure all config files are set up correctly.
#
# https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/xdb/configuring_servers/configure_a_content_delivery_server
# https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/xdb/configuring_servers/configure_a_processing_server
#
#
$xlsFile = "c:\temp\Config_Enable-Disable_Sitecore_8.1_upd3.xlsx"