We are trying the use Content Fragment APIs to create fragments.
We have defined a new content fragment at location: /conf/sample/settings/dam/cfm/models/test-cf
Using API we have the following code:
String template = "/libs/settings/dam/cfm/templates/simple/jcr:content";// default template
Resource templateResource = getFragmentTemplateResource(request.getResourceResolver(), template);
Resource parent = request.getResourceResolver().getResource("/content/dam/we-retail");
ContentFragment newContentFragement = fragmentManager.create(parent, tempResource, "P11", "P11");
This successfully creates content fragment but it use OOTB content fragment model and when we open P11 content fragment from within AEM, we get rich text to enter values.
How can we link our content model but still use OOTB content fragment template?
We are on AEM 220.127.116.11 (CFP) plus Content Fragment feature packs (cq-6.3.0-featurepack-19008-1.0.6.zip and cq-6.3.0-featurepack-19614-1.0.8.zip)
We looked at defining our own template https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/content-fragment-templates.htm...
But this needs AEM 6.3 Service Pack 3 (18.104.22.168).
When you create a CF Model manually, it would create the model under its own sort of template node (jcr:primaryType as cq:Template) and you'd need to link it to a folder path via its Cloud configuration tab.
Hence, my understanding is from the path (first parameter of fragmentManager.create(...)) it would resolve the connection and from 'template' (second parameter of fragmentManager.create(...)) , it would pick the underlying CF model (child node) on its own when you use the API.
Hope that makes sense.
refer - Content Fragment Models
Apply the Configuration to your Assets Folder
When the configuration global is enabled for content fragment models, then any models that users create can be used in any Assets folder.
To use other configurations (i.e. excluding global) with a comparable Assets folder, then you have to define the connection. This is done using Configuration in the Cloud Services tab of the Folder Properties of the appropriate folder.
I am unable to find the below mentioned tab “To use other configurations (i.e. excluding global) with a comparable Assets folder, then you have to define the connection. This is done using Configuration in the Cloud Services tab of the Folder Properties of the appropriate folder."
We have our models at conf folder at /conf/sample
Also Our CF's are stored at /content/dam/sample/pageowners
Are we talking about some other folder apart from these 2.
Just to add, jcr of our Model,
In your case, if you want your CF to be created under '/content/dam/sample/pageowners' then configure '/conf/sample' in properties of 'pageowners' folder. Then create CFM under 'sample' and CF under 'pageowners' manually to check if your model gets picked up. You'd do the similar with API.
source - Content Fragment Models