1

I'm using Sitecore 9.1.1 and SXA 1.8.1.

I'm trying to set href data attribute to a Variant section in a rendering variant.

I tried to override the RenderVariantField class as mentioned in the solution for this question and it worked and returned the correct value - but only when I use it inside a variant Field. However, when I use it inside a variant Section it returns nothing.

Any idea what I can add in order to read a data attribute inside a variant section?

enter image description here

1

If you override RenderVariantField it will indeed work for a variantfield. If you want this in a section, you need to look into Sitecore.XA.Foundation.RenderingVariants.Pipelines.RenderVariantField.RenderSection in the same <renderVariantField> pipeline.

You might want to check Setting css class in SXA variant from content item or https://ggullentops.blogspot.com/2018/10/using-tokens-in-sitecore-sxa-variant.html for some extra information about attributes on sections.

1
  • thanks a lot for your answer, this is exactly what i needed – AME Jul 2 '19 at 12:14

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.