2

I'm working on a Sitecore website where author should be able to add components based on rows and columns. (Just like in Habitat).

If the markup was simple, like this:

<div class="row">
 <div class="col-md-6">...</div>
 <div class="col-md-6">...</div>
</div>

my rendering with dynamic placeholders will be :

<div class="row">
 <div class="col-md-6">
  @Html.Sitecore().DynamicPlaceholder("col-wide-1")
 </div>
 <div class="col-md-6">
  @Html.Sitecore().DynamicPlaceholder("col-wide-2")
 </div>
</div>

But what if the markup is :

<div class="row">
 <div class="col-lg-6 col-md-6 col-sm-6">...</div>
 <div class="col-lg-6 col-md-6 col-sm-6">...</div>
</div>

On what width should I base my placeholder naming on - md/lg/sm?
Please also consider, different lg/sm/md widths for a div. For making it simple, I put the width as 6 for all devices.
Thank you.

6
  • Which implementation of dynamic placeholders are you using? Most of the implementations I've seen would not work if you are passing in the same key twice in the same rendering.
    – Ben Golden
    Commented Jan 11, 2017 at 15:06
  • It's not the marketplace component. I am using the one which appends a number. But how is that related to the naming.
    – sukesh
    Commented Jan 11, 2017 at 15:08
  • Why do you need to pass placeholder name like this one (col-wide-1) ? Personally I am not sure what your issue is. I would use keys for placeholders which are completely disconnected from current grid system. Is there any hidden intention for using that names? Commented Jan 11, 2017 at 15:52
  • 1
    I just wanted to make sure your first example really worked. It wouldn't for many implementations of dynamic placeholders. Even in Habitat, the second placeholder uses the key col-wide-2 for the second column.
    – Ben Golden
    Commented Jan 11, 2017 at 16:05
  • @BenGolden Sorry. It was a mistake. Corrected it now.
    – sukesh
    Commented Jan 23, 2017 at 5:54

1 Answer 1

5

Your placeholder keys should not depend on your markup at all. They should be based on something more abstract like how the placeholder is intended to be used. You should also consider how you want to manage the placeholder settings.

In the case of a bootstrap grid, you could use the concept column width to control which renderings are allowed in different placeholders. However, if all of your components are fluid, specifying a width might not have value for you. In that case, you could just use col-1, col-2, etc. This would decrease the number of placeholder setting items you need to maintain.

You may also want the consider the usage of the parent rendering. For example, if you need to restrict certain renderings to a footer, you could use a key like footer-1.

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.