Posts

Showing posts with the label XM Cloud

Extending Edge GraphQl Schema To Support Custom Fields In XM Cloud

Hello everyone! In this blog, we'll explore how to extend the GraphQL schema to support custom fields. In XM Cloud, when using the preview endpoint and running a search GQL query, all item versions are returned rather than just the latest ones. This can be challenging for authors who need to verify results in the page builder, as it relies on the preview endpoint for executing GQL queries. In this blog, we will add _latestversion to supported field types in GQL schema. We will extend Sitecore.Services.GraphQL.EdgeSchema.Services.SearchService . Below is the code for your references. namespace Foundation.Services { using System; using System.Collections; using System.Linq.Expressions; using System.Reflection; using Sitecore; using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch; using Sitecore.Services.GraphQL.EdgeSchema.GraphTypes.Search.Models; using Sitecore.Services.GraphQL.EdgeSchema.Services; using Sitecore.Services.GraphQL.EdgeSchema.S...

Custom Link Expansion in Sitecore: A Deep Dive into ExpandDynamicLinks in Link Provider

Hello everyone, This blog is continuation of my previous blog where we have seen how we can override the default link provider in XM Cloud. Now let's understand, how we can customize the behavior of links available withing Rich Text field. In Sitecore, managing links correctly is crucial—especially when dealing with Rich Text fields, emails, or content reuse across multiple sites. One of the key methods that helps with this is ExpandDynamicLinks, available in the LinkProvider class.Let’s explore what this method does, why it matters, and where you might use or override it in your Sitecore solution What is ExpandDynamicLinks? The ExpandDynamicLinks method is part of the Sitecore.Links.LinkProvider class. It's used to scan HTML or text content and replace Sitecore’s dynamic links (like ~/link.aspx?...) with friendly, human-readable URLs. Method Signature public virtual string ExpandDynamicLinks(string text, bool resolveSites); Parameters: text : A ...

Implementing Custom Link Provider in Sitecore XM Cloud

Image
Hello everyone, In this blog post we will see how we can override link provider class in Sitecore XM Cloud with a practical usecase. In Sitecore XM Cloud, the default link provider helps generate URLs based on the item's path and configured routing rules. However, in many real-world scenarios, marketers and content authors need more flexibility—like overriding the generated URL with a custom one defined at the content level. This blog walks through a custom link provider use case where a template includes a field such as "Override URL", allowing authors to specify a different link for a given page Let's walk through the scenario. Imagine you have a Search Page in Sitecore that includes an "Override URL" field. Now, create a sample content item—for example, a News Article page under a News folder. Whenever a component on this News Article page tries to generate a link to the main Search Page, we want to intercept this behavior. If the Search Page’s "O...

Moving Roles From Traditional XP To XM Cloud Using Sitecore Serialization

Hello everyone! In this blog post, we'll explore an essential concept in Sitecore — Sitecore Roles — which remains relevant across all platforms. Recently, I was working on a migration project where we needed to move Sitecore roles from a traditional XP solution to XM Cloud. Naturally, the first solution that came to mind was using Sitecore Serialization, as it's the go-to method for item migration. However, I quickly discovered that this approach doesn’t work as expected — roles cannot be serialized as IAR files. So, what now? After diving into the Sitecore documentation, I found the right approach — and I’m sharing it with you in this blog. Keep reading to find out how to successfully migrate roles to XM Cloud! The solution is that we need to module.json file which defined your roles only. The change will be that this should be deploy to your XM cloud instance as part of post deploy action mentioned in xmcloud.build.json file Step 1: Create a Foundation.Roles.module.jso...

Extend Page Props Factory in Sitecore XM Cloud to Inject Custom Data into the Layout Service

Image
Hello everyone! In this blog, we'll explore how to extend the page props factory plugin to add our own custom fields. We will take a realistic example to understand the concepts. XM Cloud is based on the SXA framework. In SXA, there was an option to add and manage the favicon directly from the CMS. However, this functionality is not available in XM Cloud. Instead, the favicon is typically placed in the public directory of your Next.js application to ensure public accessibility. If you want the favicon to be managed exclusively through the CMS, what approach can be taken to achieve this? So let's get started with CMS changes.First Step will be to add favIcon template with favIcon field. Second will be to add that template as base template for your main Settings item. Follow the below screenshot. Let's see the FE changes that we need to do. Create a new file called CustomContextResolver.ts under lib --> page-props-factory --> plugins Add the below code. Check...

Customizing Sitecore Next JS Static Path Build Time By Extending Multisite Plugin

Image
In this blog, we’ll explore how to customize the build-time behavior during Static Site Generation (SSG) in an XM Cloud–based application. As you may know, most of our pages are statically generated during the frontend build process and are then served from Vercel's servers or CDN. This significantly boosts page load speed and improves overall site performance. But the key question is — how can we customize this process? Often, we have pages in the CMS that are quite old — for example, blog posts that were published 10 years ago. The goal is to exclude such outdated pages from the SSG process by omitting their routes during build time. As a result, these pages won’t be pre-rendered; instead, they will be generated on-demand when a user requests them, allowing the server to handle the rendering dynamically.We will divide this blog into 2 part. Part 1: First part will be how to get the pages that we want to exlude and store it some where. Part 2: Pass these list of pages to grap...

Automate RSS Feed to Sitecore XM Cloud: Logic App, Next.js API & Authoring API Integration

Image
Hello everyone, In this blog, we will see a pratical use case of reading RSS feed and creating the respective items in Sitecore XM Cloud. To accomplish the task, we will use Logic App, an API created in Next JS and lastly calling the Authoring API to execute mutation query for Item Creation in Sitecore. Let's divide the process into 2 parts: Logic App : This will mostly focus on fetching the feed from RSS, performing transformation, storing the result in array of json object and pushing the data to next js api endpoint. Next JS API Development : This will take care of calling the authoring api of XM Cloud instance and performing the create item mutation query on the recieved data from Logic App. Logic App Azure Logic App is a cloud-based service provided by Microsoft Azure that allows you to automate workflows and integrate applications, data, services, and systems without writing complex code. It enables you to create automated workflows visually through...

Automating Tag Update in Sitecore XM Cloud with PowerShell - A Use Case

Managing tags across different environments in a Sitecore setup can be a challenging task, especially when dealing with a large number of items and multiple folders. Automating the synchronization or updating of these tags can save time and reduce errors. In this blog post, we'll explore a practical use case of using Sitecore PowerShell Extensions (SPE) to automate the synchronization of tags between shared and global environments in a Sitecore instance Use Case Imagine you are managing a global website for a large corporation, such as ABC company. Your content is distributed across various regional sites, and each region uses a different set of tags stored in different folders.The respective page content are tagged with site specific tags. However, for consistency,The business ask you to ensure that tags from the shared environment should be used from now on. But there is catch while you make the changes. You need to make sure that all existing website content pages should be ta...