19

In SXA's out of the box renderings, I see datasource locations that look like this:

query:$site/*[@@name='Data']/*[@@templatename='Custom Folder']

Is $site the only token supported here? Can I inject my own tokens?

22

SXA tokens

There are other tokens as well:

  • $compatibleThemes - path to all themese
  • $theme - currently used theme
  • $pageDesigns - root of page designs
  • $partialDesigns - root of partial designs
  • $currenttemplate - name of the current template
  • $tenant - path to the current tenant
  • $site - path to the current site
  • $home - path to the current site start item (Home)
  • $linkableHomes - paths home items from linkable sites (see cross-site linking)
  • $templates - path to the current sitetemplates
  • $siteMedia - path to Virtual Media folder located under site
  • $sharedSites - for multiroot fields, resovles shared site for current tenant.
  • $rvSystemTemplates - returns list of templates defined in a configuration. Those template are used to feed AllowedInTemplates field for rendering variants.
  • $xaRichTextProfile - returns XA.Foundation.Editing.DefaultRichTextProfile setting value.

How to define custom tokens

You can define your own tokens by adding an additional processor to resolveTokens pipeline

| improve this answer | |
2

Updated with 9.3 Resolve and Query Tokens

Resolve Tokens

  • $compatibleThemes - path to all themes.
  • $theme - currently used theme.
  • $pageDesigns - root of page designs
    (sitecore/content/Tenant/Site/Presentation/Page Designs).
  • $partialDesigns - root of partial designs
    (/sitecore/content/Tenant/Site/Presentation/Partial Designs) .
  • $currenttemplate - name of the current template.
  • $tenant - path to the current tenant.
  • $site - path to the current site.
  • $home - path to the current site start item (by default:
    /sitecore/content/Tenant/Site/Home).
  • $linkableHomes - paths to home items from linkable sites.
  • $templates - path to the current site templates
    (/sitecore/templates/Project/Tenant).
  • $siteMedia - paths to media folders specified in Additional Children field on virtual media folder item.
  • $sharedSites - for multiroot fields, resolves shared site for the
    current tenant.
  • $rvSystemTemplates - list of templates defined in a configuration.
    These templates are used to feed the AllowedInTemplates field for
    rendering variants.
  • $xaRichTextProfile - the XA.Foundation.Editing.DefaultRichTextProfile setting value.

Query Tokens

The resolveSearchQueryTokens pipeline is used to add search filters. This pipeline is defined in the Sitecore.XA.Foundation.Search.config file. By default, the following tokens are available:

  • TaggedTheSameAsCurrentPage|SxaTags
  • TaggedWithAtLeastOneTagFromCurrentPage|SxaTags
  • UnderCurrentPage
  • ExcludeCurrentPage
  • ItemsOfTheSameTemplateAsTheCurrentPage
  • ItemsWithTheSameValueInField|FieldName

9.3 documentation link

| improve this answer | |
0

please follow below links for details in token customization.

https://doc.sitecore.com/developers/sxa/18/sitecore-experience-accelerator/en/create-a-custom-token-for-a-rendering-variant.html

You have to extend the "resolveVariantTokens" processor.

| improve this answer | |
  • This is not what the OP asked. There's a difference between the varianttokens and tokens. He has to extend the "resolveTokens" processor instead of "resolveVariantTokens". There are also plenty of great guides for that though, e.g. blog.binboy.net/post/sxa-create-custom-token-query – T_D Oct 21 '19 at 14:44

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.