4

I am really new to Sitecore and I have run into a problem. I have a placeholder called "sectionBlock" that I am using multiple times on one page. The view rendering that I have allowed it to use is called "TextBlock" with a template also called TextBlock. I created three content items using the TextBlock template and gave each different field values. When I go to the experience editor, I am clicking on one of the placeholders and dropping in a TextBlock view rendering item. When I go to change the datasource to one of the content items I created, it changes the other blocks to also use that datasource. What am I doing wrong with this?

Also, if there is a better way to accomplish what I'm trying to do, I would like to know. I basically want to create multiple sections on the page with the same layout and template but different content.

  • What version of Sitecore – Chris Auer Nov 23 '19 at 1:22
  • I'm building it on 9 but it will be used on 8. – Olivia Shettles Nov 25 '19 at 14:37
6

If you're going to use a placeholder multiple times on a given page you need to use a Dynamic Placeholder instead. That will append a suffix to the placeholder value when the rendering is added to the page so that it is unique. In your view instead of

@Html.Sitecore().Placeholder("YourPlaceHolderKey")

You'd use

@Html.Sitecore().DynamicPlaceholder("YourPlaceHolderKey")

This is built-in functionality starting with Sitecore 9. If your instance is using an earlier version there are several modules put out by the community that adds this functionality.

For more on dynamic placeholders and other options that are available with it. https://doc.sitecore.com/developers/90/sitecore-experience-manager/en/dynamic-placeholders.html

| improve this answer | |
0

It does not seem like the issue is the placeholder based on the problem description but more that the datasource of all renderings in the placeholder changes when one is changed.

Dynamic placeholders can be useful but are probably too advanced for someone just learning Sitecore.

If the issue is occurring in Experience Editor try changing the datasource in Content Editor.

We will need to know the version of Sitecore you are using but it could just be a caching issue which I've seen on early versions of 8.

If you have permission you can clear the Sitecore cache by going to /sitecore/admin/cache.apsx

What you are trying to do is correct as a placeholder can have multiple renderings of the same type with different datasources.

| 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.