Skip to content

Instantly share code, notes, and snippets.

@matthewkenny
Last active April 15, 2017 09:54
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 matthewkenny/bad6e2ad020b8079c1d022d176045cf8 to your computer and use it in GitHub Desktop.
Save matthewkenny/bad6e2ad020b8079c1d022d176045cf8 to your computer and use it in GitHub Desktop.
Blog - When Personalisation Breaks Rendering Parameters - Code
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<pipelines>
<mvc.customizeRendering>
<processor type="Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering.Personalize, Sitecore.Mvc.Analytics"
set:type="MyNamespace.ResetParametersOnSubstitutedRenderings, MyAssembly" />
</mvc.customizeRendering>
</pipelines>
</sitecore>
</configuration>
public class ResetParametersOnSubstitutedRenderings : Personalize
{
protected override void ApplyChanges(Rendering rendering, RenderingReference reference)
{
// If the rendering being applied is different from the original renderings
if (!rendering.RenderingItem.ID.Equals(reference.RenderingItem.ID))
{
// Fetch the default rendering parameters for the new rendering
rendering.Parameters = new RenderingParameters(reference.RenderingItem.Parameters);
}
// Continue to apply the built-in changes
base.ApplyChanges(rendering, reference);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment