Skip to content

Instantly share code, notes, and snippets.

@jammykam
Last active October 20, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jammykam/631f66902babd10ea4377552e95ee0a5 to your computer and use it in GitHub Desktop.
Save jammykam/631f66902babd10ea4377552e95ee0a5 to your computer and use it in GitHub Desktop.
Custom Sitecore ConfigReader to allow setting custom include folder locations
using System.Configuration;
using System.Xml;
using Sitecore;
using Sitecore.Configuration;
using Sitecore.Diagnostics;
namespace MyProject.Custom
{
class ConfigReader : Sitecore.Configuration.ConfigReader
{
protected override void LoadAutoIncludeFiles(XmlNode element)
{
Assert.ArgumentNotNull((object)element, "element");
base.LoadAutoIncludeFiles(element);
string customFolder = ConfigurationManager.AppSettings["Sitecore.Include.Custom"];
ConfigPatcher configPatcher = this.GetConfigPatcher(element);
this.LoadAutoIncludeFiles(configPatcher, MainUtil.MapPath(customFolder));
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="sitecore" type="MyProject.Custom.ConfigReader, MyProject.Custom" />
...
</configSections>
<appSettings>
<add key="Sitecore.Include.Custom" value="/App_Config/Custom_Include" />
...
</appSettings>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment