Saturday, 8 September 2018

Sitecore 9 Dynamic Placeholders And Why we need them

As many of us have faced the issue of repeating content when trying to use same placeholder name, Sitecore 9 has filled this gap by introducing support for Dynamic Placeholders in Out of the Box installation.

Problem Statement and when to use Dynamic Placeholders:
In the below example I will reproduce an issue when I use a standard Sitecore placeholder:
That is:

I have created here:

  1. Layout.cshtml  - A layout file with 3 placeholders: Header, Main, Footer
  2. Sublayouts 
      • Section - A sublayout view with following code:
      • 1 Column - A sublayout view with following code.
  3. A Hero image component - This a sample component for example. We can use any other component. It contains 2 fields: Title, Image.
Important Note: None of the above placeholders will allow us to add a rendering in it if we don’t create a placeholder setting item for them under: /sitecore/layout/Placeholder Settings.