2

I have recently upgraded from SC 8.2 to 9.0.2 During the process, I had to rename the custom implementation for dynamicplaceholders to get it to work.

Following the recommendation in https://www.symsoftsolutions.com/blog/2018/07/31/sitecore-8-to-9-quick-upgrade/

Now facing an issue with compatible renderings. I have some compatible container components (using dynamicplaceholders) for placing other card components.(content) The container components in this use case are for enabling the design for single of multiple card placements.

When we switch the components (dynamic placeholder containers) the content is lost. Root cause is that the content is associated with the dynamicplaceholder key which changes during the switch and they don't render.

Tried....

Change the calls to SC9 provided Dynamicplaceholders. Disabled all pipeline overrides.

Behavior with SC 9 Dynamicplaceholders is exactly the same. All that changed is the key format.

Any suggestions / workarounds?

1
3

Workaround

This is a bug in the Experience Editor. You can work around this issue by changing the rendering in Presentation Details with the Change button.

Root Cause

When you replace a rendering with a compatible rendering in the Experience Editor, a new unique ID is generated for the rendering. As Chris Auer mentioned, Sitecore's implementation of Dynamic Placeholders is based on the unique ID of the rendering containing the placeholder, so the new unique ID breaks your placeholders. The Change button in Presentation Details does not generate new unique IDs, so does not have this issue.

Fix

To fix the Experience Editor, you just have to patch the ReplaceRendering pipeline processor.

Pipeline Processor

using Sitecore.Data.Items;
using Sitecore.Layouts;
using Sitecore.Pipelines.ExecutePageEditorAction;

namespace YourAssembly.Pipelines.ExecutePageEditorAction
{
    public class ReplaceRenderingWithDynamicPlaceholders : ReplaceRendering
    {
        protected override RenderingDefinition DoReplaceRendering(
            RenderingDefinition sourceRendering,
            Item targetRenderingItem,
            DeviceDefinition device)
        {
            // Preserve the UID of the original rendering so that dynamic placeholders will continue to work
            var rendering = base.DoReplaceRendering(sourceRendering, targetRenderingItem, device);
            rendering.UniqueId = sourceRendering.UniqueId;
            return rendering;
        }
    }
}

Config Patch

Make sure you replace YourAssembly with the appropriate namespace and assembly name.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <group groupName="ExperienceEditor" name="ExperienceEditor">
        <pipelines>
          <executePageEditorAction>
            <processor type="YourAssembly.Pipelines.ExecutePageEditorAction.ReplaceRenderingWithDynamicPlaceholders, YourAssembly"
                       patch:instead="*[@type='Sitecore.Pipelines.ExecutePageEditorAction.ReplaceRendering, Sitecore.ExperienceEditor']" />
          </executePageEditorAction>
        </pipelines>
      </group>
    </pipelines>
  </sitecore>
</configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.