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.

  • 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 Jan 11 '17 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. – Qwerty Jan 11 '17 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? – Alan Płócieniak Jan 11 '17 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 Jan 11 '17 at 16:05
  • @BenGolden Sorry. It was a mistake. Corrected it now. – Qwerty Jan 23 '17 at 5:54
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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.