Book Image

Sitecore Cookbook for Developers

By : Yogesh Patel
Book Image

Sitecore Cookbook for Developers

By: Yogesh Patel

Overview of this book

This book will get you started on building rich websites, and customizing user interfaces by creating content management applications quickly. It will give you an insight into web designs and how to customize the Sitecore architecture as per your website's requirements using best practices. Packed with over 70 recipes to help you achieve and solve real-world common tasks, requirements, and the problems of content management, content delivery, and publishing instance environments. It also presents recipes on Sitecore’s backend processes of customizing pipelines, creating custom event handler and media handler, setting hooks and more. Other topics covered include creating a workflow action, publishing sublayouts and media files, securing your environment by customizing user profiles and access rights, boosting search capabilities, optimising performance, scalability and high-availability of Sitecore instances and much more. By the end of this book, you will have be able to add virtually limitless features to your websites by developing and deploying Sitecore efficiently.
Table of Contents (20 chapters)
Sitecore Cookbook for Developers
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Empowering the Experience Editor using placeholder settings


Being a content owner, the Experience Editor provides a simpler user interface to change the page design. In this recipe, we will take a look at how to add components from the Experience Editor using Placeholder Settings.

Getting ready

In the previous recipe, we placed different components on different placeholders, for example, the Title and Body rendering on the main-content placeholder. We will place Carousel or any other rendering on the same placeholder from the Experience Editor.

How to do it…

As we want to place components on the main-content placeholder of the Home page from the Experience Editor, we will first create a placeholder setting for it:

  1. From the Content Editor, select the /sitecore/layout/Placeholder Settings item. Create a placeholder setting main content item in it. In its Placeholder Key field, enter the name of the placeholder that we defined in the Main Layout, for example, main-content.

  2. Now open the Home page in the Experience Editor. Find the Title and Body rendering that is placed on the main-content placeholder, as shown in the following image. From the floating toolbar visible there, click on Go to parent component to reach its parent component, which is the main-content placeholder in our case. Now, you will find two Add here buttons in the main-content placeholder to place components before and after the Title and Body rendering:

    Note

    As an alternative to this step, you can also find all the placeholder settings on the page directly. For this, from the Experience Editor ribbon, in the Home tab, in the New group, click on the Component button.

  3. Clicking on this button will open a Select a Rendering dialog, from which you can select a component to add to that place. Select the Carousel rendering to place it before the Title and Body rendering, save the changes, and see how your page has been changed!

How it works…

There are two types of placeholder settings: global placeholder settings and data template specific placeholder settings.

In the preceding steps, we used the global placeholder setting as we specified a placeholder key in the placeholder setting. So, whenever Sitecore finds the main-content placeholder in any component of the requested page, it will allow us to manage components on that placeholder. In our case, it will be shown on all the pages of the website. So ideally, it's good practice to use the global placeholder setting for placeholders of the main layout of the site.

We can also set placeholder settings on the data template level. For example, we want to restrict the main-content placeholder setting only for Site Root or other selected templates. For this, we should follow these steps:

  1. In the placeholder setting that we created, don't specify the Placeholder Key field (leave it blank) so that we can override it on the template level.

  2. Select the standard values of the Site Root template. Open its Layout Details, and select the Select the Placeholder Settings tab in the Device Details dialog. Click on the Add button, which will open the Placeholder Setting dialog. Here, select the created placeholder setting, main content, and set the main-content placeholder name, as shown in the following image, and save the settings:

Now you will be wondering how Sitecore adds the components directly to Layout Details of the page. Open the Layout Details of Home item; you will find that the Carousel rendering we added from the Experience Editor got stored to FINAL LAYOUT, where SHARED LAYOUT is still the same as before, as shown in the following image. This is because of the Versioned Layouts feature we got from Sitecore 8. Read more about it at https://goo.gl/FXxHkP:

You can also remove any components by clicking on the Remove component. button found on the floating toolbar of the component, as shown in the following image:

Learn more about the Experience Editor at https://goo.gl/1ZFIpX.