Has anyone tried it? What are the steps needed to create a custom variant field, and is it worth it to create a variant field for videos (or any custom variant fields in general)?
I can answer your first 2 questions, but whether it's worth it seems opinion based.. It can be if your requirements need it (and it's worth the effort).
So yes, I tried it. Blogged about it: https://ggullentops.blogspot.com/2019/04/sitecore-sxa-custom-rendering-variant-translation.html
How (short version):
- Create a template to define the fields of the variant (check the ootb ones)
- To have your field available in the insert options when people create a variant definition, add it to the insert options (tip: use the rules engine)
- You need a model that inherits from
- Creating instances of this model is done by a processor that inherits from
- Next is the processor that renders the variant, inheriting from
Sitecore.XA.Foundation.Variants.Abstractions.Pipelines.RenderVariantField.RenderRenderingVariantFieldProcessorand focusing on the
Add the processors to the config:
<sitecore> <pipelines> <parseVariantFields> <processor type="Foundation.Dictionary.RenderingVariants.ParseDictionaryText, Foundation.Dictionary" resolve="true"/> </parseVariantFields> <renderVariantField> <processor type="Foundation.Dictionary.RenderingVariants.RenderDictionaryText, Foundation.Dictionary" resolve="true"/> </renderVariantField> </pipelines> </sitecore>