Rendering Contents Resolvers
Mohamed Sirajudeen
Senior Sitecore Consultant at INSCALE |??2x Sitecore Technology MVP |??4x Sitecore? Certified |??AI Enthusiast |???Blogger |???Speaker
In this article, we are going to see how we can use Layout Service to resolve the rendering contents. So, Sitecore Headless provide us to resolve the context or datasource content items using the Layout service. The resolvers that Sitecore offers Out of the box are as follows:
We can find these resolvers under the rendering items.
For Example, if we are using the datasource and wants to read the child items of the given datasource then we must choose the related Rendering content resolver (in this case Datasource Item Children Resolver is the correct option) in the rendering level then the layout service will automatically read the items and give the content through Json response.
How this Rendering Content Resolver works in real time scenario ?
As we have up and running local next.js application, we can create a component called “Root Rendering Component” by using scaffolding.
jss scaffold RootRenderingComponent
once we created the Component, we should define the below code as part of this component.
After this step, we need to create the Sitecore template, rendering (using Json Rendering) in Sitecore.
Next step to create a component called “Child List Rendering Component” by using scaffolding.
jss scaffold ChildListRenderingComponent
once we created the Component, we should define the below code as part of this component.
领英推荐
After this step, we need to create the Sitecore template, rendering (using Json Rendering) in Sitecore.
When we have the Sitecore content for data source that will have a parent of “RootRenderingComponent” including the child items of “ChildListRenderingComponent”.
If we add the “RootRenderingComponent” in page level and try to run the application in connected mode, it will not show any child items.
In Sitecore, see the below image how the data source of “RootRenderingComponent” contains the child items of “ChildListRenderingComponent”.
When we add the Rendering Contents Resolver as a “Datasource Item Children Resolver” and save it.
If you go and check the experience editor after selecting the "RootRenderingComponent" rendering, the result will be like the below image.
As per the code above component contains the list of child items of the datasource.
I hope you all understand how the Rendering contents resolver works in Sitecore Headless.
That’s the end of this article.
Happy Sitecoring !!!