How do I use my custom components in designing/building an experience fragment? Can I create a custom template and use it in creating an experience fragment? Or the last available option is to use a layout container and use it in creating an experience fragment.
This is really a nice question. Let me answer it 1 by 1:
How do I use my custom components in designing/building an experience fragment?
We can not this directly. As the user who is creating the Experience fragment should not be having rights to configure the allowed components.
Can I create a custom template and use it in creating an experience fragment? Or the last available option is to use a layout container and use it in creating an experience fragment.
Yes, this should be the approach.
We should create an Editable template "Tools> General > Templates" and therein layout container we can configure policies (here we can configure which all component groups to be included or excluded) and later use this templates for creating Experience fragment
Step2:- Enable this template and later use this templates for creating Experience fragment
Step3:- In CRX/de go to /content/experience-fragments and in cq:allowedTemplates add the path of newly created Template in step 1. Now you are good to go. Now when you create
PS:- You can avoid Step 2 and 3 and can directly use We-retail template available. Just change policy as per your need.
So I'm looking at the documentation for creating Experience Fragments And I want to create a fragment from a custom template; the same way the we-retail sample project does.
So I go about creating a template, they try to create my fragment from that template only to find that my template does not show up as one of the options... ok.. I look into how we-retail did it and I copy the web variation template to my own directory under /conf.. still not working..
At this point, I do a google search and I arrive here.. and I see you are mentioning that you need to add the location of the template to the cq:AllowedTemplates prop of the node /content/experience-fragments.
Now I have two questions:
1. Why is this not documented in the official documentation? The whole point is to be able to create your own templates and fragments, right? So the use of cq:AllowedTemplates prop of the node /content/experience-fragments should be well documented.
2. How is the we-retail sample implementation adding the path to cq:AllowedTemplates automatically? I can see this entry added to cq:AllowedTemplates: `/conf/we-retail/settings/wcm/templates/experience-fragment(.*)?` But I dont see where in the we-retail code it's being added?