Dynamic Placeholders

Dynamic Placeholders for Sitecore allows you to add the same placeholder name several times. This can be across one or more renderings and even the same placeholder can be used multiple times in a single rendering.

How does it work?

Dynamic Placeholders simply use the rendering ID to create a unique placeholder name. If more than one dynamic placeholder with the same name is in a rendering it will also append on an incrementing number. Behind the scenes the Dynamic Placeholders extracts the placeholder name to ensure the correct allowed renderings are shown.

Requirements

  • Sitecore 8+
  • MVC

Installation

To enable Dynamic Placeholders in your Sitecore solution you can install the MVC NuGet package mentioned above.

Install-Package DynamicPlaceholders.Mvc

Once the package is installed you’ll then need to add the namespace to the Views\Web.config.

<system.web.webPages.razor>
	<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
	<pages pageBaseType="System.Web.Mvc.WebViewPage">
		<namespaces>
			<add namespace="DynamicPlaceholders.Mvc.Extensions" />
		</namespaces>
	</pages>
</system.web.webPages.razor>

Usage

Adding Dynamic Placeholders is very easy and the following code snippet shows how.


<div class="column">
	@Html.Sitecore().DynamicPlaceholder("content")
</div>

One Comment

  1. Pingback: Predicting the placeholder for a dynamic placeholder - Technology

Comments are closed.