Contact Us

As JSS attains more valuable features, most tech architectures are now integrating or incorporating it. The Sitecore JSS is the framework for developing JavaScript applications capable of building interactive UI components with relevant plugins. If you have earlier functioned on different architectural patterns within Sitecore, like MVC, you might uncover instances demanding Content resolvers.

The article guides you toward creating custom content resolvers. The most fundamental use of the content resolvers is to enable you to operate on more intricate data. You will get to a point where you need to return data to the layout service, which does not come from rendering data sources or context items.

We will have to create our custom Rendering Content Resolver. Here are a few Rendering Content Resolver out of the box from Sitecore Layout Service:

  • Datasource Resolver: The default behavior serializes the rendering's data source item
  • Datasource Item Children Resolver: Serializes the children of the data source item
  • Context Item Resolver: Serializes the context item instead of the data source item
  • Context Item Children Resolver: Serializes the children of the context item
  • Folder Filter Resolver: Serializes the descendants of the data source item, excluding folders
  • To create your custom content resolver, you will have to inherit from the RenderingContentsResolver class.
  • After creating the custom content resolver, assign it to a Rendering Content Resolver in Sitecore (/sitecore/templates/System/Layout/Layout Service/Rendering Contents Resolver).

Image 1

  • Next, assign it to a JSON Rendering.(/sitecore/layout/Renderings)

Image 2

  • After this, you can now use your JSON Rendering in your JSS Route.

 

Conclusion

The content resolvers are the built-in means to enable you to configure the renderings in a manner so that the data returned matches the configuration. The above process is straightforward and very quick to perform. Therefore, it will achieve your simple rendering requirements. However, there could be situations where the returned data for rendering requires various modifications for which Sitecore is adaptable and has defined solutions. For more such queries, and solutions contact our team today.

Need Help?