Configuration options for the Layout Service

Version: 22.x

When you want to modify the behavior of the Layout Service, you can use configuration files to change the maximum depth for serialization, include or exclude paths, and more.

The Layout Service configuration accepts the following attributes:

  • serializableRenderingTypes.

  • serializationMaxDepth.

  • paths.

  • configurations.

The serializableRenderingTypes attribute

You can use the serializableRenderingTypes attribute to define the list of rendering IDs that can be present as JSON while getting the rendering result.

For example:

RequestResponse
<layoutService> 
    <serializableRenderingTypes>
        <sublayout>{0A98E368-CDB9-4E1E-927C-8E0C24A003FB}</sublayout>
        <viewRendering>{99F8905D-4A87-4EB8-9F8B-A9BEBFB3ADD6}</viewRendering>
        <controllerRendering>{2A3E91A0-7987-44B5-AB34-35C2D9DE83B9}</controllerRendering>
        <xslRendering>{F1F1D639-4F54-40C2-8BE0-81266B392CEB}</xslRendering>
        <jsonRendering>{04646A89-996F-4EE7-878A-FFDBF1F0EF0D}</jsonRendering>
    </serializableRenderingTypes>
</layoutService>

The serializationMaxDepth attribute

You can specify the maximum depth for items retrieved in linked fields with the serializationMaxDepth attribute. The default value is 4.

For example:

RequestResponse
<layoutService> 
    <serializationMaxDepth>4</serializationMaxDepth>
</layoutService>

The paths attribute

You can use the excludePaths element to specify excluded paths.

For example:

RequestResponse
<layoutService> 
    <paths>
        <excludePaths>
            <path id="1">/sitecore/system</path>
            <path id="2">/sitecore/templates</path>
            <path id="3">/sitecore/layout</path>
            <path id="4">/sitecore/media library</path>
            <path id="5">/sitecore/social</path>
        </excludePaths>
    </paths>
</layoutService>

The configurations attribute

Using the configurations node, you can define named configurations that allow overriding the default Layout Service behavior.

For example:

RequestResponse
<layoutService> 
    <configurations>
        <config name="default">
            <requestContext type="Sitecore.LayoutService.Configuration.DefaultRequestContext, Sitecore.LayoutService">
                <databaseName>master</databaseName>
            </requestContext>

            <rendering type="Sitecore.LayoutService.Configuration.DefaultRenderingConfiguration, Sitecore.LayoutService">
                <placeholdersResolver type="Sitecore.LayoutService.Placeholders.DynamicPlaceholdersResolver, Sitecore.LayoutService" />

                <itemSerializer type="Sitecore.LayoutService.Serialization.ItemSerializers.DefaultItemSerializer, Sitecore.LayoutService" resolve="true">
                    <AlwaysIncludeEmptyFields>true</AlwaysIncludeEmptyFields>
                </itemSerializer>

                <renderingContentsResolver type="Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver, Sitecore.LayoutService">
                    <IncludeServerUrlInMediaUrls>true</IncludeServerUrlInMediaUrls>
                </renderingContentsResolver>
            </rendering>

            <serialization type="Sitecore.LayoutService.Configuration.DefaultSerializationConfiguration, Sitecore.LayoutService">
                <transformer type="Sitecore.LayoutService.Serialization.LayoutTransformer, Sitecore.LayoutService" resolve="true" />
            </serialization>
        </config>
    </configurations>
</layoutService>

Do you have some feedback for us?

If you have suggestions for improving this article,