Rendering content of Widget Zone twice

Vincent Broeke asked on May 10, 2022 17:03

Is it possible to render the content (widgets) of a widget zone twice inside a single section? It looks like the content is only rendered once, while the widget zone is declared twice, like this:

<section>
    <div class="styling-for-desktop">
        @Html.Kentico().WidgetZone("my-widget-zone")
    </div>
    <div class="styling-for-mobile">
        @Html.Kentico().WidgetZone("my-widget-zone")
    </div>
</section>

This would allow me to duplicate the content of a widget zone for two separate stylings.

Correct Answer

Brenden Kehren answered on May 11, 2022 13:37

You might want to rethink this approach. This could cause a lot of performance issues if you have duplicated widgets on a page simply to have a "global" class to hide or show the elements by.

You might look at letting breakpoints in your css handle this work. Or do some additional work in your widget to display content twice while only getting it once.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Vincent Broeke answered on May 11, 2022 14:56

The code example above is a simplified version of the actual HTML that is a bit more complex. Which makes duplicating widget content a bit harder because there are multiple area's and widgets involved. I might want to take this back to our front-end development team to see what they can do.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.