Resolving Sitecore placeholder settings issue related to Query.MaxItems config

Posted 30 Aug 2024 by Marek Musielak

sitecore add rendering to a placeholder

One of the questions in Sitecore developer training asks why a newly added placeholder in a view file might not be rendered in Experience Editor, preventing content authors from adding components to that placeholder. The answer suggests that the Sitecore placeholder definition item with the specified placeholder key was likely not created. But there may be another reason. In this blog post, I will explain how Sitecore determines how to render placeholders in Experience Editor and discuss a potential issue that may arise if the Query.MaxItems config value is set too low.

I wrote this blog post while working for Blastic, a company that delivers great Sitecore solutions and much more.

When a content author opens a page in Experience Editor, each time Sitecore encounters a placeholder in the view code, it checks whether that placeholder can be designed. This check uses a PlaceholderCache class which stores the cached information about all the placeholder definition items in Sitecore. This class contains Reload method which uses code similar to the one below to get all the placeholder settings:

this.Database.SelectItems($"{PlaceholdersRootItem.Paths.FullPath}//*[@@templateid = '{PlaceholderSettingsItemTemplate}']");

This line of code, in the combination with the default value of Query.MaxItems in Sitecore 10 which is 100 (see config below) will result in the issue if you have more than 100 placeholder definition items in your solution. Is having more than 100 placeholders a typical scenario? Not really I believe. However, in a multibrand, multitenant solution with components that can only be placed in strictly limited placeholders, this scenario may occur.

<!--  

  Query.MaxItems

  Specifies the max number of items in a query result set.
  If the number is 0, all items are returned. This may affect system performance, if a
  large query result is returned.
  This also controls the number of items in Lookup, Multilist and Valuelookup fields.
  Default value: 100

-->
<setting name="Query.MaxItems" value="100" />

So, am I in trouble if I have more than 100 placeholder definition items in my Sitecore solution? Not really: just create a configuration patch file and increase the Query.MaxItems value to make sure it returns all the placeholders in PlaceholderCache class:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="Query.MaxItems">
        <patch:attribute name="value">200</patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

In this article, I delve into a specific issue where placeholders added in Sitecore may not show up in the Experience Editor, often due to configuration settings rather than missing definitions. By understanding how Sitecore handles placeholder rendering and the role of the Query.MaxItems setting, I provide a straightforward solution to ensure all placeholders are correctly displayed.

Comments? Find me on or Sitecore Chat