官术网_书友最值得收藏!

Restricting or swapping rendering controls on placeholders

While adding renderings from the Experience Editor, by default, it allows you to add all the renderings from the /sitecore/layout/Renderings folder. However, just imagine how difficult it would be for content owners to choose a logically valid and compatible rendering from the huge list.

In this recipe, you will learn how we can show a template-specific list of the allowed and placeholder-compatible renderings from the Experience Editor.

Getting ready

We have the main-content placeholder placed on all pages of the website. We want to restrict content authors to use Carousel, Highlight Featured Products, and Highlight News renderings only on the Home page. Similarly, for the Products landing page, we will restrict them to use Carousel and Highlight Featured Products renderings only. This recipe assumes that you have created the mentioned renderings.

How to do it…

Here, we will first override placeholder settings for the data template of the Home page:

  1. From the Content Editor, select standard values of the Site Root template. Open the Placeholder Setting dialog from the Device Editor. Remove any placeholder settings, if any. Create a new setting.
  2. Set the Name to Home Content and the Placeholder Key field to our main-content placeholder key. In the Parent field, select the main content placeholder setting that we have already created. Here, select the required renderings from the Allowed Controls field:
    How to do it…
  3. Open the Home page in the Experience Editor. Add the renderings to it; you will find that only the preceding selected renderings will be available to pick, as shown in the following image:
    How to do it…
  4. In the same way, you can apply these settings to standard values on Product or any other template, as per your requirement.

How it works…

Once you create this placeholder setting, you will find a new item created in the main content placeholder setting item, where you will find all the selected renderings in the Allowed Controls field:

How it works…

You can also change placeholder settings from the Experience Editor by clicking on the highlighted button in the floating bar of the placeholder, as shown in the following image:

How it works…

You learned how to place allowed controls on placeholders. Sitecore renderings have a Compatible Renderings field, as shown in the following image, where you can select compatible renderings to a particular rendering. So, while replacing any rendering from the Experience Editor, it will allow you to choose renderings from the selected compatible renderings only. For example, as shown in the following image, Sitecore will allow you to replace Carousel rendering with Banner rendering only. You can learn more about it at http://goo.gl/Tk5ybI:

How it works…
主站蜘蛛池模板: 东乌珠穆沁旗| 衡阳县| 虹口区| 漳浦县| 桃园县| 泰兴市| 弥渡县| 长兴县| 武隆县| 定州市| 绍兴市| 新余市| 民权县| 蓝山县| 西安市| 同心县| 普兰店市| 四川省| 林周县| 娱乐| 溧水县| 报价| 乌审旗| 广饶县| 闸北区| 金平| 楚雄市| 三穗县| 新宁县| 吴江市| 岚皋县| 宾阳县| 长兴县| 高雄市| 郯城县| 宣武区| 教育| 恩施市| 山东| 驻马店市| 娱乐|