Skip to content

Instantly share code, notes, and snippets.

View jraps20's full-sized avatar

John Rappel jraps20

View GitHub Profile
[Validator("Language Fallback Invalid", Status.Error, Description = "Validates all fields support language fallback. Add new properties to ignore templates that start with a particular path.")]
public class LanguageFallbackValidator : UserConfigurableValidator
{
private static readonly Guid Template = new Guid("{AB86861A-6030-46C5-B394-E8F99E8B87DB}");
public override IEnumerable<Problem> Validate(Dictionary<Guid, SitecoreDeployInfo> projectItems, XDocument scprojDocument)
{
var list = new List<Problem>();
foreach (var projectItem in projectItems)
{
<indexableRenderings>
<rendering name="RichText" id="{4F8942FF-C4E4-408A-B3D5-4657EE5050CA}" />
</indexableRenderings>
@jraps20
jraps20 / GetDatasourceDependencies.cs
Last active January 12, 2018 22:17
Full set of classes and config changes required to index modular content in Sitecore, i.e. content that is added to the page as a separate rendering with a datasource. Configured to only index certain renderings based on config, to disallow indexing of renderings that may be "Related Items" or other types of renderings that are shared and not pe…
using System.Linq;
using Sitecore;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Pipelines.GetDependencies;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
namespace Common.Sitecore.Search.GetDependencies
{
var remoteEvent = new LogMessageRemoteEvent(Sitecore.Configuration.Settings.InstanceName, "logMessage:remote");
Sitecore.Eventing.EventManager.QueueEvent<LogMessageRemoteEvent>(remoteEvent);
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor type="MyNamespace.LogMessageRemoteMap, MyDll" method="Initialize" />
</initialize>
</pipelines>
</sitecore>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="logMessage:remote">
<handler type="MyNamespace.LogMessageRemote, MyDll" method="LogInstanceName" />
</event>
</events>
</sitecore>
</configuration>
var args = new GetScreenShotForURLArgs(item.ID);
CorePipeline.Run("getScreenShotForURL", args);
@jraps20
jraps20 / GeneratePdf.cs
Created October 24, 2017 03:49
Gist to illustrate saving a PNG generated via Sitecore PhantomJS as a PDF.
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using Sitecore.ContentTesting.Pipelines.GetScreenShotForURL;
namespace MyLibrary.GetScreenShotForURL
{
public class GeneratePdf : GenerateScreenShotProcessor
{
public override void Process(GetScreenShotForURLArgs args)
{
@jraps20
jraps20 / AddTimeoutToScript.cs
Created October 24, 2017 03:46
Gist to illustrate modifying the PhantomJS default timeout of zero to a new value
using Sitecore.ContentTesting.Pipelines.GetScreenShotForURL;
namespace MyLibrary.GetScreenShotForURL
{
public class AddTimeoutToScript : GenerateScreenShotProcessor
{
public string Timeout { get; set; }
private const string StandardExit = "phantom.exit();\r\n});";
@jraps20
jraps20 / SitecorePdf.xml
Last active October 24, 2017 03:44
Config file for use in Sitecore PDF Generation
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getScreenShotForURL>
<!-- Disable security check -->
<processor type="Sitecore.ContentTesting.Pipelines.GetScreenShotForURL.CheckDisabler, Sitecore.ContentTesting">
<patch:delete />
</processor>