This content originally appeared on DEV Community and was authored by Sebastián Aliaga
Content Resolvers in Sitecore XM Cloud allow developers and content authors to dynamically determine the source of data for individual renderings. These resolvers provide the flexibility needed to pull content from different areas of the Sitecore content tree based on specific rules or criteria. This guide will explain what each type of content resolver does and how they can be utilized within your project.
Types of Content Resolvers
1. Context Item Children Resolver
The Context Item Children Resolver retrieves all the child items of the current context item. This is useful when you need to display a list of child elements, such as when creating a navigation menu or a list of related articles.
2. Context Item Resolver
The Context Item Resolver pulls content from the current context item, which is typically the item representing the current page. This is the most basic content resolver and is often used when the component should display content directly from the page itself.
3. Datasource Item Children Resolver
The Datasource Item Children Resolver fetches all the children of a specified datasource item. This resolver is ideal when you want to display multiple related pieces of content that are stored under a specific datasource in the content tree.
4. Datasource Resolver
The Datasource Resolver retrieves content from a specific datasource that has been set for a rendering. This is commonly used when you want to specify a static content source (e.g., a folder of reusable content) for a component, such as a promotional banner.
5. Folder Filter Resolver
The Folder Filter Resolver retrieves content from a folder, but with additional filtering criteria. For example, you might use this resolver to pull only items of a certain template type or with specific field values from a folder.
6. Sitecore Forms Resolver
The Sitecore Forms Resolver is specifically designed to retrieve and render Sitecore forms. It’s useful when integrating forms into a page, such as a contact form or feedback form, without manually linking each form to a component.
Experience Accelerator Resolvers
In addition to the default rendering content resolvers, Sitecore XM Cloud offers additional resolvers under the Experience Accelerator section. These resolvers are designed to enhance the flexibility of Sitecore SXA projects by adding specific content-handling capabilities.
7. HTML Variant as JSON Serializer
This resolver serializes HTML variants as JSON. It’s typically used when content needs to be serialized and transferred in a JSON format for use in headless or API-driven applications.
8. Image Contents Resolver
The Image Contents Resolver fetches images from the datasource and is used to display images within components. It simplifies how image assets are linked and managed within components, ensuring they are pulled dynamically from the content tree.
9. Link List Contents Resolver
The Link List Contents Resolver is designed to retrieve a list of links, such as navigation links, social media links, or related content links. It is useful for managing multiple links in a single datasource and displaying them dynamically.
10. Navigation Contents Resolver
This resolver is designed to retrieve content that is used in navigational components, such as menus or breadcrumbs. It can pull items based on their hierarchy in the content tree, ensuring that the site structure is accurately reflected in the navigation.
11. Page List Contents Resolver
The Page List Contents Resolver pulls a list of pages, which can be used to create components like related articles, a blog post list, or category overviews. It retrieves the list of pages based on specific criteria such as templates or fields.
12. Rich Text Contents Resolver
The Rich Text Contents Resolver retrieves rich text content from a datasource. It is typically used for components that need to display formatted text content, such as articles, blog posts, or other content-heavy sections.
Headless Experience Accelerator Resolvers
Lastly, for headless implementations, Sitecore offers additional resolvers under the Headless Experience Accelerator.
13. Navigation Contents Resolver
Similar to the navigation resolver in the Experience Accelerator, this resolver is used specifically in headless environments to retrieve and present navigational content. It ensures that navigation menus and structures are generated dynamically, even in a headless context.
Conclusion
Content Resolvers in Sitecore XM Cloud offer a powerful way to dynamically pull and manage content across your site. By understanding the different types of resolvers, such as those for navigating content trees, retrieving images, or displaying forms, you can optimize how content is handled within your renderings. Whether you are building a static component or a dynamic navigation menu, configuring the right content resolver ensures that the correct data is fetched, leading to a more flexible and scalable website.
This content originally appeared on DEV Community and was authored by Sebastián Aliaga
Sebastián Aliaga | Sciencx (2024-09-26T17:20:43+00:00) Understanding Content Resolvers in Sitecore XM Cloud. Retrieved from https://www.scien.cx/2024/09/26/understanding-content-resolvers-in-sitecore-xm-cloud/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.