Lala
Lala

Reputation: 378

Inner renderings not displaying

In a page, I have a rendering with a placeholder, Offcanvas.cshtml

<div data-ads-offcanvas-id="@Model.Id" class="ads-offcanvas @Html.GetCssStyles()">
@{
    <a data-ads-offcanvas-trigger-id="@Model.Id" class="ads-close-button" href="#0">X</a>
    @Html.Sitecore().Placeholder(LayoutHelper.GetPlaceholder(Placeholders.AccordionSection, Model.Id))
}

and inside that rendering, I plan to put another rendering with a placeholder named Modal.cshtml

<div data-ads-modal-container="@Model.Id" class="ads-modal-container">
<div class="ads-modal-dialog">
    <div class="ads-close-box">
        <a data-ads-modal-id="@Model.Id" href="#0">X</a>
    </div>
    <div class="ads-modal-content">
        @Html.Sitecore().Placeholder(LayoutHelper.GetPlaceholder(Placeholders.AccordionSection, Model.Id))
    </div>
</div>

So it looks like:

-Offcanvas
+-Modal
++-Text content

When I put text content inside the Modal rendering, the content is not rendered. I'm guessing that it only renders that first few renderings and fail to do so when the renderings became highly nested.

Is there a solution to render components to the very-most child?

Thanks guys!

EDIT: Here's the code for GetPlaceholder:

public static string GetPlaceholder(string name, Guid id)
    {
        return $"{name}_{id}";
    }

Upvotes: 1

Views: 604

Answers (1)

Nathan Hase
Nathan Hase

Reputation: 659

Dynamic placeholders are a bit more complicated than generating a unique placeholder key. The generated key still needs to resolve back to a real placeholder that is defined in Sitecore.

Check out the Integrated Dynamic Placeholder module.

This will provide an Html helper similar to your current implementation:

@Html.Sitecore().DynamicPlaceholder("[Placeholder Name]")

Upvotes: 1

Related Questions