Reputation: 21
We have created some reusable components for our site and have hit a problem when trying to add more than one instance of these component to a page. This is an issue because Sitecore needs the placeholder key to be unique. Does this mean you can never add more than one instance of a sublayout with a placeholder on to the same page?
Example:
Two column sublayout - placeholders 2column-col1 and 2column-col2 Three column sublayout - placeholders 3column-col1, 3column-col2 and 3column-col3 On the page add a two column sublayout, a three column sublayout and then another two column sublayout There are now 2 placeholders with the name 2column-col1 and 2 placeholders with the name 2column-col2
Is there any way around this? We thought of dynamically creating the placeholder key in the user control code behind but this causes problems if you want to use placeholder settings.
It seems that it would be a common thing to want to do. Is there a workaround?
Upvotes: 2
Views: 2371
Reputation: 6890
I believe this is a duplicate of your SDN post, but for reference I will link my blog post (with prototype solution code) here as well.
http://www.techphoria414.com/Blog/Dynamic%20Placeholder%20Keys%20Prototype.aspx
Upvotes: 2
Reputation: 113
In Sitecore 6.3.1 there is a setting in web.config
<!-- DUPLICATE PLACEHOLDERS
Indicate whether to process duplicate placeholders
Default value: false
-->
<setting name="Rendering.ProcessDuplicatePlaceholders" value="false" />
I think this setting is available on all versions of Sitecore 6.
You should give it a try and change it to "true".
Upvotes: 1
Reputation: 4170
What you can do is dynamically create the placeholder keys to get the desired functionality and then manually create 5-6 placeholder setting items and duplicate the settings for all of them. I have done this in one project and it works well even though it's very ugly.
If you are using sitecore 6.4+ you might even be able to use cloned items to create the placeholder settings. This way you will be able to control the allowed sub-layouts from the original item and all the rest will just inherit the values.
Hope that helps.
Upvotes: 3