How do I make use of Sitecore Dictionary Labels in SXA Rendering Variants? I want the CTA Text to come from Dictionary. It will have two texts namely "View More" and "View Less" in 3 languages.
At the moment there is no ootb solution to do this. We had a similar issue and decided to write our own variant definition to accommodate this. Our idea was to have a variant similar to
Text variant, but instead of the actual text you could give the key of the dictionary.
My blog post on the topic explains in detail how to create this custom variant. In short, you need to:
- create a template for the variant (and set insert options for it)
- create a model that matches the template
- create a parse processor (inherit
Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.ParseVariantFields.ParseVariantFieldProcessor) to create a model from the variant item
- create a render processor (inherit
Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.RenderVariantField.RenderRenderingVariantFieldProcessor) that does the actual rendering
- add both processors to the config
Note: do set the SupportedTemplateID in the parse processor and check the model in the render processor as all variants go through the same pipelines.