Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

InvalidTemplateException while creating content fragment - ContentFragmentManager API

Avatar

Level 1

Hi,

I am trying to create a content fragment using com.adobe.cq.dam.cfm.ContentFragmentManager create method. I tried giving different content fragment model resources at create(Resource parent, Resource template, String name, String title). It always giving com.adobe.cq.dam.cfm.impl.InvalidTemplateException: Invalid template format; missing 'version' attribute.

Am I missing anything here?

@Reference

ContentFragmentManager cfm;

--

Resource parent = resourceResolver().getResource("/content/dam/fragments");

Resource template = resourceResolver().getResource("/conf/global/settings/dam/cfm/models/custommodel");// content fragment model in my local

ContentFragment contentFragment = cfm.create(parent, template, "samplefragmentname", "sample fragment title");

resourceResolver().commit();

Thanks,

Raja

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

CF Model is not same as CF Template. That's the issue in this case. Either you create a CF template or use an existing editable template for the same. Create a CF manually and you'd get to know more about it.

Resource template = resourceResolver().getResource("/conf/global/settings/dam/cfm/models/custommodel");  // provide template path rather than CF model path

Refer - Content Fragment Templates

View solution in original post

0 Replies

Avatar

Correct answer by
Community Advisor

CF Model is not same as CF Template. That's the issue in this case. Either you create a CF template or use an existing editable template for the same. Create a CF manually and you'd get to know more about it.

Resource template = resourceResolver().getResource("/conf/global/settings/dam/cfm/models/custommodel");  // provide template path rather than CF model path

Refer - Content Fragment Templates

Avatar

Level 1

I tried with template. It is working. Thanks Gaurav!

Thanks,

Raja

Avatar

Level 1

I used OOB simple template

/libs/settings/dam/cfm/templates/simple/jcr:content

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now