Add a dynamic placeholder to a rendering variant
SXA lets you create rendering variants that render a placeholder that enables users to add additional renderings. You can add restrictions to the placeholder settings. For example, because you only want the content author to add an image rendering. When you use dynamic placeholders, you can add the same placeholder name several times across multiple renderings or within a single rendering. Dynamic placeholders guarantee that unique keys are used across different renderings and within one rendering.
Dynamic placeholders in SXA do not work with personalization rules. When switching variant, personalization does not allow rendering parameters to be changed.
To add a dynamic placeholder to a rendering variant:
-
Add a rendering variant. For example, add a variant for the Page Content rendering.
-
Right-click the variant, click Insert and click Placeholder.
-
In the VariantDetails section, add the Placeholder Key. Do not use a dash in your Placeholder Key name, this may impact the key resolving logic. If you leave the field empty, the key will be generated automatically.
WarningYou must not change Placeholder Keys when they are in use, nor change the order of existing placeholders, nor add a placeholder before any of the existing ones. Once a placeholder is generated on the page (with a Placeholder Key assigned) and it contains renderings, changing the key will make the renderings disappear. The renderings will be hidden because they cannot find their placeholder path.
-
If you want the user to be able to switch context for the renderings inside this placeholder, go to the VariantDetails section and select the Switch component context to currently rendered item check box.
-
To reference the placeholder key that you just created in the Placeholder Settings, go to Presentation/Placeholder Settings and add a placeholder.
-
In the Data section, enter the Placeholder Key that you just created and add an * to make it dynamic and guarantee a uniqueness to the placeholder key across different renderings.
-
If you want to restrict the use of renderings in this placeholder, in the Data section, in the Allowed Controls field, click Edit and select the renderings that are allowed. For example, go to Layout/Renderings/Feature/Experience Accelerator/Media and select the Image rendering.
-
If you now add the Page Content rendering to the page and select the variant that you just created, you will see that the only available rendering that you are allowed to add is Image: