I have the page with placeholder and list. I want to be able to fill the list with information depending on the items in the placeholder. For example:
I have "Person" template with Name and Image Fields. I creat few items based on that template (person A, B and C). After adding the renderings with these items as a source, I display images in the placeholder. Now I want to get all the item that are currently in the placeholder and write theirs Name field into the list(which is outside placeholder).
For now I was just able to get the rendering item, but not source item, out of placeholder.
I was able to get source items by Id that I found in Settings of RenderingItem:
var ph = "my_placeholder";
var renderingReferences = Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, true);
var renderingsInPlaceholder = renderingReferences.Where(r => r.Placeholder.EndsWith('/' + ph, StringComparison.OrdinalIgnoreCase));
var items = renderingsInPlaceholder.Select(x => context.GetItem(ID.Parse(x.Settings.DataSource)));