Placing renderings dynamically using placeholders
In the previous recipes, you learned placing components on a layout or view statically. You can empower the dynamic placement of components using a placeholder, which comes with lots of benefits that you will learn in this recipe.
How to do it…
We will first replace statically placed renderings with placeholders in Main Layout
:
- We will first decide places where we can put content dynamically or we need placeholders, for example, breadcrumb, side menu, and main content area.
- From
Main Layout
, remove the existing renderings from these places and add placeholders,breadcrumb
,left-colum
n
, andmain-content
as follows:<div class="container"> <div id="breadcrumb"> @Html.Sitecore().Placeholder("breadcrumb") ...
Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.