Created
January 17, 2020 15:19
-
-
Save joostbroekhuizen/91f217b1724628f43ff4b021b2b41f60 to your computer and use it in GitHub Desktop.
Custom Sitecore JSS Descendants resolver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Builds a tree-like structure of datasource item's descendants | |
/// </summary> | |
/// <seealso cref="Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver" /> | |
public class DescendantsRenderingContentsResolver : Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver | |
{ | |
protected override JObject ProcessItem(Item item, IRenderingConfiguration renderingConfig) | |
{ | |
var jObject = base.ProcessItem(item, renderingConfig); | |
if (item.Children.Count == 0) | |
{ | |
return jObject; | |
} | |
jObject["items"] = ProcessItems(item.Children, renderingConfig); | |
return jObject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment