10

I have this code nested down 3 deep in placeholders i.e. /MainFrame/ContentMain/ and then there is this Dynamic Placeholder I am wanting to use:

<!-- Right Content -->
<div class="col-sm-4">
    @Html.Sitecore().DynamicPlaceholder("ContentSectionRight")
</div>

I have not used Dynamic Placeholders for Sitecore 9 yet so I am unsure how to set this up in the rendering. I am using /MainFrame/ContentMain/ContentSectionRight but that is not working, and my component is not showing up. I know my component is working because if I move i to /MainFrame/ContentMain it will show up.

What is the correct way to render my component using the NEW Dynamic Placeholders in Sitecore 9?

2
  • 1
    Are you adding the component via the experience editor or presentation details and typing the placeholder key in?
    – Richard Seal
    Nov 30, 2017 at 15:26
  • I am adding in via the Presentation Details from the Content Editor at this point. Nov 30, 2017 at 15:29

1 Answer 1

11

The key for a dynamic placeholder uses the parent unique rendering Id to become dynamic, it also appends an incremental number in case you want multiple placeholders. In your example:

<!-- Right Content -->
<div class="col-sm-4">
    @Html.Sitecore().DynamicPlaceholder("ContentSectionRight")
</div>

So you have created a placeholder key of ContentSectionRight - when you add a component to that via the experience editor, you will notice that the key becomes ContentSectionRight-{00000000-0000-0000-0000-000000000000}-0- obviously, the guid of its parent rendering unique Id will be added in there.

If you want to add a component via presentation details, you will need to look in the __Renderings or __Final Renderings raw values to get the Id that would be used. It is usually a lot easier to just use the Experience Editor to add your components.

3
  • After looking into your first comment about using the Experience Editor, that is exactly what I did, and it added it in correctly. Then I went over to the Final Layout in the Presentation Details in the Content Editor and voila, there was the key as such: /MainFrame/ContentMain/ContentSectionRight-{393B1F3D-763A-470C-8848-E65E2043DFD1}-0. This is different from the "_" as Sitecore uses dashes, but nonetheless 99% correct, and is marked as the answer. Much agreed, use the Experience Editor for adding your components as the Primary unless situations dictate otherwise. Thanks Richard! Nov 30, 2017 at 15:44
  • Updated to use the hyphens
    – Richard Seal
    Nov 30, 2017 at 16:26
  • Now 100% correct. Thanks again Richard and happy coding! Nov 30, 2017 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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