1

Is there any way for me to add placeholders programatically inside the SXA rendering variant. I have tried using the * at the end of the name of placeholders but I keep getting some weird errors and the whole site just crashes.

Here is what I mean by this:

const string key = "carousel-1-*"
@Html.Sitecore().Placeholder(key)

I keep getting erros when I use this. Also, the model is VariantListsRenderingModel

2
  • Have you tried @Html.Sitecore().DynamicPlaceholder("key")?
    – Ashish
    Commented Mar 10, 2022 at 19:55
  • @Ashish I have not tried that. But I will try it
    – Samke11
    Commented Mar 10, 2022 at 20:04

1 Answer 1

3

Instead of placeholder, just need to DynamicPlaceholder like below -

@Html.Sitecore().DynamicPlaceholder("key")

No need to give *, this DynamicPlaceholder will manage a unique by itself like below -

enter image description here

Your Answer

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

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