InvalidTemplateException while creating content fragment - ContentFragmentManager API | Community
Skip to main content
February 20, 2019
Solved

InvalidTemplateException while creating content fragment - ContentFragmentManager API

  • February 20, 2019
  • 4 replies
  • 1395 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

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

4 replies

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
February 20, 2019

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

February 20, 2019

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

Thanks,

Raja

March 7, 2019

Can you please share the template path you used?

March 15, 2019

I used OOB simple template

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