﻿#### 

### Definition

I think each Sitecore developer knows that there are two possible ways to manage item's presentation components (renderings and sublayouts):

- The Experience Editor
- The Content Editor

The Experience Editor is really an effective tool for managing item content and list of renderings, but Experience Editor does not work for all sites and all pages. Also it is not the fastest way to add a single component because loading the EE takes some time.

The second way, the Content Editor, allows us to add renderings and sublayouts faster. Unfortunately, it is less comfortable because we need to know the exact placeholder's name to which we want the rendering to be added. Also, the lists of allowed renderings and sublayouts are unlimited and we have to look for the necessary component through all renderings and sublayouts defined in Sitecore:

![renderings and sublayouts defined in Sitecore](https://www.brimit.com/-/media/images/blog/renderings1.png?la=en&amp;hash=94421A966B35B4862B5AE400E0EBA4E3)

I’ve been working with Sitecore for about five years; and I was always thinking how comfortable it would have been to have a list of placeholder’s names in which selected rendering or sublayout can be used. I decided to implement such a solution myself.

Recommended Rendering Module provides a list of recommended renderings that potentially can be used with current item and the collection of placeholder names where selected rendering can be added:

### Implementation

Module implementation can be logically divided into two parts: preparation of the list of renderings and the list of placeholders.

Implementation of both parts is based on the lucene search index which contains the following types of items:

![Recommended Renderings](https://www.brimit.com/-/media/images/blog/renderings2.png?la=en&amp;hash=9FDB77BFC0204F085EA198BB877EF50D)

- Content items (https://www.brimit.com/sitecore/content by default)
- Placeholder Settings (https://www.brimit.com/sitecore/layout/Placeholder Settings by default)

First, the index with two location for paths was configured:

![index with locations for path](https://www.brimit.com/-/media/images/blog/renderings3.png?la=en&amp;hash=EA040D5E4A2F4F4074F16F5F71B04A4E)

But during testing there was an issue with updating nodes from the second location. After spending some time for investigation I found out the article ([http://sitecore.stackexchange.com/questions/3480/issue-with-multiple-crawlers-on-solr-custom-search-index](http://sitecore.stackexchange.com/questions/3480/issue-with-multiple-crawlers-on-solr-custom-search-index "search index issue")) where this issue was described. Sitecore was able to provide a patch for the SitecoreItemCrawler class. It doesn't appear to be on their Github so I can't link it but I asked for support DLL 108165. The issue is fixed in Sitecore 8.2 Update 1. I didn’t want to trouble module user by any updates of sitecore and prepared two configurations: with single index and two locations configured and with two indexes where each of them was configured for one location. By default, the module is configured for using two indices as this configuration definitely work with all versions of sitecore. Please, make sure you have downloaded an appropriate version of module.

Index includes just two fields “Allowed Controls” and “Placeholder Key” of the Placeholder template and one computed field that prepares a list of renderings that are used on the item. It’s enough for us to get necessary data for building module.

The list of **recommended renderings** is based on the renderings that are already used with current item plus renderings that are used on the items with the same template. Each of them are already assigned to some placeholders. I’ve prepared a list of placeholders and found the renderings that are specified for these placeholders in the Placeholder Settings. After that I can extend the recommended renderings list with newly found placeholders. This way, a rendering will be included into the recommended list in several cases:

- a rendering is already used on an item;
- a rendering is already used on an item with the same template;
- a rendering is specified for placeholder that is presented on the item;

The list of **recommended placeholders** is prepared for selected rendering (on the original control or on the recommended rendering). I look for all items where this rendering is used and get placeholders from there + find the placeholder settings that included the selected rendering and extend the list with it.

As a result, we have two lists that should be shown to the users and it is not less complicated. Sitecore has the TreeviewEx control that is used on the Select Rendering dialog. But the control can process only items from Sitecore’s root, it can’t work with virtual items and it doesn’t match my requirements because the data I want to display comes from the search index. The solution was to implement custom control ([RecommendedRenderingTreeview](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/Controls/RecommendedRenderingTreeview.cs "RecommendedRenderingTreeview")) that have the same behavior with the Sitecore TreeviewEx. In order to add the new control to the Select Rendering dialog, I had to override it. The most correct way to do that it is to put the custom [SelectRendering.xml](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/sitecore/shell/Override/Applications/Dialogs/SelectRendering/SelectRendering.xml "SelectRendering.xml") (code is here: [CustomSelectRendering.cs](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/Controls/CustomSelectRendering.cs "CustomSelectRendering.cs")) to the override folder by the following path:

*/sitecore/shell/Override/Applications/Dialogs/SelectRendering/*

So the RecommendedRenderingTreeview is added to the SelectRendering.xml and the last thing I needed was to pass a current item’s ID from the SelectRendering dialog to the custom treeview. After investigation I haven’t found any way to get the current ID from the SelectRendering dialog. I decided to override the [DeviceEditor.xml](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/sitecore/shell/Override/Applications/Layouts/DeviceEditor/DeviceEditor.xml "DeviceEditor.xml") (code is here: [CustomDeviceEditor.cs](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/Controls/CustomDeviceEditor.cs "CustomDeviceEditor.cs")) dialog and pass the current item ID to SelectRendering by query string parameter. If you know a better way - please let me know.

When we select any rendering, we call the SelectableItemPreview\_Click method to prepare the recommended placeholders list. And to display the prepared list we add [RecommendedPlaceholders.js](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/sitecore/shell/Controls/RecommendedPlaceholders/RecommendedPlaceholders.js "RecommendedPlaceholders.js") and [RecommendedPlaceholders.css](https://github.com/ampach/Recommended-Renderings-Module/blob/master/Module/sitecore/shell/Controls/RecommendedPlaceholders/RecommendedPlaceholders.css "RecommendedPlaceholders")

### Configuration

The module has three configuration files:

- **RecommendedRenderings.config** - includes a general settings of module and contains the following settings:
    - ContentRootPath - Recommended Renderings will be shown just for the selected root item and his children. It is better to specify a content root which you currently work with. It will reduce a time of rebuild index and preparing the recommended renderings list. Default value: /sitecore/content
    - DatabaseName - Determines the database that is used by the Recommended Renderings module to prepare the list of recommendations. It have to be the same database which is configured for the "recommended-renderings-index" index. Usually it is "master" and wouldn't be changed. Default value: master
    - IsExpandedDefault - If true, the Recommended Renderings tree will be expanded by default. Default value: false
    - PlaceholderSettingsRootPath - Recommended placeholders list will be shown just for the selected root item and his children. It is better to specify a content root which you currently work with. It will reduce a time of rebuild index and preparing the recommended placeholders list. 

        Default value: /sitecore/layout/Placeholder Settings
    - TreeviewRootIcon - Default icon for root element of the recommended renderings list. Default: Applications/16x16/windows.png
- **Z.RecommendedRenderings.ContentSearch.Configuration.config** - defines a search index configuration. It’s different for each of versions of Sitecore and should not be changed.
- **Z.RecommendedRenderings.ContentSearch.Index.config** - defines a search index. It’s also different for each of versions of Sitecore. The Crowling locations should be the same with pathes that defined in the ContentRootPath and PlaceholderSettingsRootPath settings of RecommendedRenderings.config

### Installation

**WARNING:** The module will override the Sitecore’s default SelectRendering and EditDevice dialogs. You always will be able to restore them if needed (see the Uninstall section). BUT make sure that you haven’t already overridden this dialogs on your environment. If so, we do not recommend to install the module. Please [contact me](https://www.brimit.com/contact-us "Contact Brimit") in this case and we will solve it individually.

Follow the steps below for installing module:

- Make sure that you downloaded the correct version of the module.
- Install downloaded package using installation wizard.

Optional Step. The install package has a post install step that should rebuild the index automatically, but if in case module doesn't work after installation, you need to rebuild index manually:

- Go to the Index Manager and build the following indexes: **recommended-renderings-index** and **recommended-placeholders-index** *NOTE*: If you use the Sitecore v.8.2 or earlier version, you will need to build just recommended-renderings-index.

### Uninstall

If you don’t like the module or in some other reasons you want to uninstall the module, remove files by the following paths:

1. sitecore\shell\Override\Applications\Dialogs\SelectRendering\SelectRendering.xml
2. sitecore\shell\Override\Applications\Layouts\DeviceEditor\DeviceEditor.xml
3. sitecore\shell\Controls\RecommendedPlaceholders
4. sitecore\shell\Controls\RecommendedRenderingTreeview
5. App\_Config\Include\RecommendedRenderings
6. bin\RecommendedRenderings.dll

Check out the Recommended Renderings Module on the [Sitecore Marketplace](https://marketplace.sitecore.net/Modules/R/Recommended_Renderings.aspx "ecommended Renderings Module "). And [tell us](https://www.brimit.com/contact-us "Contact Brimit") what you think!

###### Author

[!\[artsiom-photo\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/artsiom-200.jpg?h=202&amp;iar=0&amp;w=200&amp;hash=41797D2540DF6EB6FDF558360F6F62B8)
Artsem Prashkovich
Sitecore MVP/ Solution Architect](https://www.brimit.com/blog/author?authors=Artsem%20Prashkovich)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=ae95ce83-9f46-42f6-9dcf-549d4cb4a372&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=Recommended%20Renderings%20Module&amp;kw=Sitecore,%20editor,%20renderings,%20sublayouts,%20recommend,%20module,%20placeholders%20&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Frecommended-renderings-module&amp;r=&amp;lt=273&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=997253)