If you’ve done a site in Sitecore, you know about the Dynamic Placeholders. It’s been a critical part of supporting the Editing Experience.  In Sitecore 9, this feature is now out of the box!

The markup is as simple as you need it to be:

Simply change:

to

in order to render out four placeholders named “main”.

But wait, there’s more!  Looking at the definition for the DynamicPlaceholder method, there’s quite a few variations on the signature:

I’ve highlighted an interesting one here.  Check out the DynamicPlaceholderRenderContext parameter.  This allows us to do some neat things, such as specifying a class name that is unique for every placeholder.  Without clunky code!

If we take the example of the main placeholder with 4 dynamic holder inside, and put in a simple rendering that just has plain “Lorem Ipsum Dolor” text in it, we get something like the rendered content below:

You can see that everything is just on one line.  That’s technically good, as each placeholder doesn’t render anything but the renderings inside.  Let’s put each of those placeholders as a div, so we can get some separation:

That give us the following:

What if we wanted to apply a certain style to just certain divs in here, though?  Sitecore has a handy ability to generate just a bit more data for us on the back end…again…without the clunk.

We can see that we’re passing in the input, which is the rendered contents.  We also have access to the context of the placeholder to grab the current index.  Check out the rendered content below:

There’s a slew of other properties available, too:

As you can see, this is pretty powerful. Being able to get this deep directly in your placeholder and not in the rendering is pretty great.


This entry is part of my series "Nine on Nine" which is a "quick peek" at nine new things in Sitecore 9.  I've been messing a bit with the Technical Preview, and there's lots of exciting stuff to share.  Some of these might change a little in regards to General Availability, but hopefully not too much... These posts won't cover everything in depth, as I hope to do more detailed analysis in the coming months. Other Entries in Nine on Nine
  1. Connecting to Sitecore Rocks
  2. Controlling Configuration Load Order
  3. Dynamic Placeholders
  4. Server Role Configuration
  5. Sitecore Forms
  6. Switching Search Providers
  7. SIF and HTTPS Everywhere
  8. Using Set in Configuration Files
  9. Infrastructure Software changes
There's more than just nine new things.  XConnect is a huge change to how data is collected.  Cloud-first support is another big thing.  Look to the official RSS Community Blog Feed, check out the Sitecore Slack Channel, hit up the Sitecore Stack Exchange or leave the Official Forums for more information.  It's a great time to be a Sitecore Developer! Facebooktwittergoogle_plusredditlinkedinmail