0
votes

I'm using DynamicPlaceholders in an MVC implementation of Sitecore specifically for column names in rows. For instance, I might have 3 50/50 renderings on a page, each with a column-one placeholder and a column-two placeholder. The dynamic placeholder code I'm using is working perfectly for creating new pages. But now I need to migrate existing pages from a different node into my new content tree.

I create a new RenderingDefinition item like this:

RenderingDefinition ren = new RenderingDefinition();
ren.Placeholder = "content/50-50";
ren.Datasource = [Datasource GUID];
ren.ItemID = [Rendering GUID];
device.AddRendering(ren);

Then I need to add some content items to each column of that rendering, and here's where I'm running into a problem. Somehow Sitecore stores a GUID with the above rendering I created. If you inspect the placeholder in PageEditor mode you can see a "referenceId" in the markup that corresponds to this. But I cannot figure out where it's stored so I can pass it to the following code:

RenderingDefinition col = new RenderingDefinition();
col.Placeholder = "content/50-50/column-one_[50/50 rendering placeholder guid]";
col.Datasource = [Datasource GUID];
col.ItemID = [Rendering GUID];
device.AddRendering(col);

It's definitely not a property of the RenderingDefintion, nor is it the rendering ID.

1

1 Answers

1
votes

The Guids are not stored separately but as part of the placeholder key which can be referenced by referencing DefaultPlaceholderKey property of rendering.Placeholder

Here is a good post on everything you need to know about dynamic placeholders http://johnnewcombe.net/blog/sitecore-part-3