Instantly share code, notes, and snippets.

Embed
What would you like to do?
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