20

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?

3 Answers 3

27

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.

Introduced with 10.2

  • $sitelang - the context site language.
  • $lang - the context language.
  • $vf - the virtual folder for the context site.

How to define custom tokens

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

3

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

-1

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.

1
  • 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
    Commented Oct 21, 2019 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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