How to add cq:xfVariantType to a Template for Experience Fragments?



Issue: On AEM 6.4.. When trying to refer an Experience Fragment inside an "Experience Fragment Component" on a sites/page, the "experience fragments without any "cq:xfVariantType" property do not show up. The Experience fragment functions normal.

Screen Shot 2019-09-12 at 5.30.02 PM.png

Screen Shot 2019-09-12 at 5.30.14 PM.png

As of now we have added this via code but there is not way to add this property to the "editable template" other than via crx/de. And which is not a way we can recommend to customers while building editable templates.

Screen Shot 2019-09-12 at 5.27.50 PM.png

Screen Shot 2019-09-12 at 5.33.29 PM.png

Referred this: Configure cq:xfVariantType in experience fragment. and copied the property referring to We.Retail's "Experience Fragment Web Variation" template.

Is this an error with General > Experience Fragment component?

Accepted Solutions (1)

Accepted Solutions (1)




I believe you are creating experience fragment templates using experience fragment template type.

As a developer, you still need to create template type and there you can add cq:xfVariantType property in initial content.

whenever you will create new xf template using xf template type, cq:xfVariantType property will be added to new templates.



Answers (6)

Answers (6)




The cq:xfVariantType {String} web property must be set on the initial template for it to show up.


The templates must be allowed via the cq:allowedTemplates property set at the root jcr:content node of the site.





Thanks Vish.dhaliwal we were able to identify that XF needs that property from this post. Only We.Retail example had this and is not documented anywhere on the documentation pages. Or if it is, i'm missing it.



Yes, i agree and adding them did solve the problem. But this has to be done via Code or crx/de and not via AEM UI.

When users/template-authors are building an Editable template on the AEM UI.. they cannot use them unless a "developer" is involved.

So i see the process as..

  • Build an editable template in AEM
  • Make a package out of it
  • Import that package into codebase, add the "cq:xfVariantType" property and deploy it back to AEM again.

Something is not correct here?