0

I'm attempting to use a Content Token named BrandName in a Page Title field in a multi-site headless solution (Sitecore 10.1.1 Headless 18). The hope was that I could setup the Standard Values for the field as follows: $name | $(BrandName). This would replace the $name token with the name of the Route item and the $(BrandName) token with the value specified within the Data folder of the site.

Based on the SXA documentation

The logic of content tokens replacement is implemented in the RenderContentToken processor of the renderField pipeline. You can reference a content token in a rich text, single-line text, and multi-line text field by using the $ key and the name of the content token in parentheses.

I have confirmed that this does work as expected with Rich Text fields, but not with Single Line Text or Multi-line Text fields.

In my example below, the token key is BrandName and the value is Super Huge Brand. The Route name is Home.

{
    "sitecore": {
        "context": {
            "pageEditing": false,
            "site": {
                "name": "Super Huge Brand"
            },
            "pageState": "normal",
            "language": "en",
            "itemPath": "/"
        },
        "route": {
            "name": "Home",
            "displayName": "Home",
            "fields": {
                "Page Design": {
                    "id": "640c1013-1a08-4301-bdae-324e0953b5fd",
                    "url": "/sitecore/content/Client A/Super Huge Brand/Presentation/Page-Designs/Primary-Page-Design",
                    "name": "Primary Page Design",
                    "displayName": "Primary Page Design",
                    "fields": {
                        "PartialDesigns": {
                            "value": "{79FDD9F5-E3ED-4597-BB59-C8C4E8187D10}|{3232D922-6C2E-447C-834D-50E5D1EE8A86}|{D3FFF78A-284E-4135-B826-FD91E8505DBB}|{7296CF96-E7F6-4F04-84C0-032592C57BCF}"
                        }
                    }
                },
                "PageTitle": {
                    "value": "Home | $(BrandName)"
                },
                "RichPageTitle": {
                    "value": "Home | Super Huge Brand"
                },
                "MultiLinePageTitle": {
                    "value": "Home | $(BrandName)"
                }
            },
            "databaseName": "web",
            "deviceId": "fe5d7fdf-89c0-4d99-9aa3-b5fbd009c9f3",
            "itemId": "706a68e8-349c-4a5d-bd38-38f0766171b1",
            "itemLanguage": "en",
            "itemVersion": 1,
            "layoutId": "9a4810a8-5fd1-42ac-97d8-4ad65b56c7ed",
            "templateId": "34e6c385-eb0d-4858-b173-8b0cbc919149",
            "templateName": "App Route",
            "placeholders": {}
        }
    }
}

My question is: Am I doing something wrong or is this a bug that I need to log with Sitecore?

1

I understand that you are talking about SXA/JSS sites, right?

If yes, then I'm surprised that it works for the Rich Text fields. We've never migrated content tokens to SXA/JSS sites, you won't find the Content Token field under a data for such site:

enter image description here

Implementation details: Sitecore.XA.Feature.ContentTokens.Pipelines.RenderField.RenderContentToken

2
  • Thanks @Dawid, you are correct. I am using SXA for JSS and adding my own content items into the Data folder where applicable. It sounds like Content Tokens weren't tested against JSS/Headless and I'll have to develop my own implementation if I want to leverage token functionality. Is that a fair assumption? Sep 30 at 15:00
  • 1
    @ChetCheeto Yes, we didn't add that feature to SXA/JSS sites and in order to have such functionality, you will need to implement it on your own. Sep 30 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.