Rendering Contents Resolvers

Rendering Contents Resolvers

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:

  • Datasource Resolver?– The default behavior, serializes the rendering’s datasource item.
  • Datasource Item Children Resolver?– Serializes the children of the datasource item.
  • Context Item Resolver?– Serializes the context item instead of the datasource 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.

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 !!!

要查看或添加评论,请登录

Mohamed Sirajudeen的更多文章

社区洞察

其他会员也浏览了