3

I am creating a Materialize-UI based Grid (CMS authorable) to reduce no of fixed/static layouts in the application. CMS side - I've created Row & Column templates, One grid rendering & Datasource (which has row & it's child columns with required materialize info). Code side - I've used hard code seed value i.e. 10 for the dynamic placeholder inside a foreach loop which runs equals to the no of columns suppose 5 in the datasource. For each iteration, the seed value increments by 1 (seed = 11, 12, 13, 14, 15) and creates 5 dynamic placeholders which are used to add 5 renderings/components on the page. It works fine when i publish and run the page.

However, when i delete the 4th column from the datasource, publish and run the page then, the component which was set for seed no 15, doesn't load, Because this time seed no 15 is not created which is set in the presentation details of the page.

To resolve this issue, I thought of adding a seed id for each row & column in the CMS & use that for dynamic placeholder creation and it works fine for me.

However, I think this is hard for content author to assign unique id for each Row & Column in the CMS. Therefore, I am looking for a good solution here to handle seed value dynamically?

8
  • That sounds like a potential bug with Sitecore 9.x Apr 4, 2018 at 19:02
  • This doesn't fully make sense, you are generating Placeholder in code (not in the ideal way, but that's a separate issue), but removing a rendering from inside the Placeholder is causing it to not be created? Can you post the code you use to create your palceholders.
    – jammykam
    Apr 5, 2018 at 2:34
  • Any suggestion guys? May 1, 2018 at 4:16
  • [code]@{ int index = int(default); int seedVal = 10; } <div class="container"> @Html.Sitecore().DynamicPlaceholder("grid-row", seed: 10) </div> Below columns will be placed in grid-row placeholder <div class="row"> @foreach (var gridColumn in Model.GridColumns) { seedVal = seedVal + index; @Html.Sitecore().DynamicPlaceholder("grid-column", CreateColumnWrapper(gridColumn), seed: seedVal) } </div> Note: CreateColumnWrapper(gridColumn) May 6, 2018 at 17:06
  • This is a very strange use of Dynamic Placeholders, and wrong IMO. Rather than creating each gridColumn as placeholder, you should just write the html straight out. You wouldn't have this issue then.
    – jammykam
    Jun 2, 2018 at 1:45

1 Answer 1

0

[Solved] - To avoid the content author involvement, I have used a new apporach. Instead of passing the seed id for each Row & Column from the cms, I have written a method which takes the item id as a parameter and extract the integer part of it and use it as a seed value for dynamic placeholder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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