LibrarySites.Banner

The Power of Placeholder Settings

Sitecore's Page Editor interface empowers content owners to change the design of a page.  This is a very powerful and exciting feature of the application.  One of the major concepts in maximizing the page editor experience is to properly configure placeholders and placeholder settings. In this post I'll show you how to override global placeholder settings on a per-template basis. This allows you to maintain the centralized control provided by global placeholders without sacrificing the ability to make specific changes when needed.

Placeholders

The first concept here is the placeholder itself.  These are placed on layouts, sublayouts and view renderings.  The placeholder is simply an area of the page to support the user adding controls.  In Page Editor the place holder is shown as a checked area when design mode is enabled.  Users can use the ”add to here” button or the add component button in the ribbon to add controls.

screenshot

Placeholder Settings

Once placeholders have been defined, you need to create placeholder settings.  These items provide all of the details for the placeholder to Page Editor including the controls that can be added.  These items are easy to create as they only have a few fields including a placeholder key, the allowed controls list, a description, and a checkbox call editable.

At first glance, I noticed that the placeholder key field is not required.  This seemed odd because it seems you need to have a key value, but placeholders work in multiple ways.  If you do provide a key value it must be unique, and there is validation to prevent you from having duplicates.

Global Placeholder Settings

 To have a placeholder work the same in all instances you simply need to create a settings item and specify the key.  This will now default all of the placeholders with this key to use these settings.  This is a great solution for placeholders in the site header or footer or any area that you desire to work the same in all cases.  I also recommend creating one for each placeholder value so that you will always have a settings item.  It is very important to specify the key when you create these placeholders.

In this example, you see that for the sidebar placeholder there are four controls that are allowed.

screenshot

Data Template Specific Placeholder Settings

Global placeholder settings give us a lot of power and provide the ability to restrict controls for a given placeholder, but sometimes we need more granular control.  For instance, you may want to restrict the allowed controls more for a given item or items based on a particular data template.  The latter of these is much more ideal, but the concepts also work for individual items.

For our example, we will use a site with templates called Article, Evaluator, and Contributor.  Each of these templates by default will use the same layout and the same basic page structure which includes a placeholder called content-top.  The problem is that each of these templates contains slightly different fields and each has a banner that is specific to that template.  So to summarize we have a placeholder called content-top, but the settings need to be different for each of our data templates. 

This is the use case for placeholder settings to be mapped at the data template level.

The first step is to create placeholder settings for scenario.  I create a folder in the placeholder settings folder with the name of the template.  I then create a settings item in the folder with the name of placeholder along with the name of the template.  This may seem a little redundant, but there is a very good reason for it.  I use the folder structure to keep these organized.  The name contains the template name and the placeholder name so it is easy to see what settings item is used even when the full path is not shown, but the naming is really up to you.  It is important that you leave the placeholder key value blank or Sitecore will let you know that you have duplicate keys.  The Allowed Controls field is important because it allows you to specify the controls you want for this template.

screenshot

With this item created, we can now map it on the Presentation Details of the Template Standard Values.  To do this go to your template and select the Standard Values item.  Once there open the presentation details window.  This window will allow you to see the placeholder settings you have specified for this template as well as edit them.

screenshot

 

Click Edit then select placeholder settings to see the settings configured for this item.  Once there you can also add additional placeholder settings for this template.  Simply select the settings item you created and specify the placeholder key.  In this example, we are using our new settings item to restrict the content-top placeholder only allow the contributor banner.  If we did this also for the evaluator template, we have met our requirements because the list specified in the global placeholder settings is sufficient for items based on the Article template.

screenshot

 

Conclusion

With an understanding of global and template specific placeholder settings, we need to reduce it down to the recommended usage of each.  Always create placeholder settings for your placeholders specifying the Allowed Controls to meet the generic case.  Now use template specific placeholders to override these base rules. 

  • This seems really important to protect users from themselves, and to make life easier for them.  I'll be doing this right now, thanks.

  • Hi,   I was trying this but having problem, please help.  I created global Placeholder Setting MenuEdit with empty Placeholder Key. Then i went to my templates "templates->User Defined->MyWeb->Component Templates->Navigation Elements->__Standard Values" Then on robin (Tab) I selected "Presentation" and click "Details" There i selected layout, control, and assigned Placeholder Setting with Placehoder Key.  There is not result.  But if I select node Home and open Presentation Details, and here I set Placehoder Settings with Placeholder Key it works.  Please advise where I'm doing mistake as i could not it the way you explained.  Thanks

  • Hi. I have a case where i want a placeholder(pageHeadPh) to contain a default rendering(page teaser). How do i achieve this.

  • Hi, What will happen if allowed controls are empty?