Custom Multifield in Content Fragment. | Community
Skip to main content
sesmic
Level 4
Aug 18, 2023 7:54 AM UTC
Solved

Custom Multifield in Content Fragment.

Hi all,

I am trying to create custom multi field for my content fragment referring this blog in AEM 6.5. I followed the blog but facing two below issues. 

  • When ever I refresh the CF the multi fields gets multiplied. Means if there is 1 multi field in CF, after refresh it will be doubled & again doubles upon each refresh.
  • If I use this CF on page, the data is displayed as JSON not like regular CF.

So, could anyone please tell if I'm missing something or doing wrong? Also, I observed without JS, the CF doesn't give 1st issue. I know there Adobe recommended approach also but this is requirement as of now. 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Oct 4, 2023 7:58 AM UTC

@sesmic Did you find the info shared useful? 

Kautuk Sahni

6 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
Oct 4, 2023 7:58 AM UTC

@sesmic Did you find the info shared useful? 

Translate
Kautuk Sahni
kautuk_sahni
Employee
Sep 18, 2023 7:49 AM UTC

@sesmic Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Translate
Kautuk Sahni
kautuk_sahni
Employee
Sep 14, 2023 11:26 AM UTC

Issue 1: Multifield gets multiplied when CF is refreshed

This issue is likely caused by the way you are adding the multifield to the content fragment model. To avoid this, make sure that you are using the sling:resourceType property to include the multifield component, rather than directly adding the multifield itself.

For example, instead of adding the following to your content fragment model:

  • <multifield name="myMultifield" />

You should add the following:

  • <include sling:resourceType="granite/ui/components/foundation/include" path="/path/to/multifield/component" />

 

Issue 2: Content fragment data is displayed as JSON when used on the page

This issue is likely caused by the way you are rendering the content fragment on your page. To render the content fragment correctly, you need to use the Content Fragment component.

For example, you could add the following to your page template:

  • <cq:ContentFragment contentFragmentPath="/path/to/content/fragment" />
    This will render the content fragment on your page, using the default template for the content fragment model.

Note: The composite multifield component is not officially supported by Adobe. If you are using this component, you may encounter unforeseen issues.
Link: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/content-fragments/content-fragments-models.html?lang=en

 

Note: The multiple composite multifields feature is currently in beta.
Link: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/content-fragments/content-fragments-models.html?lang=en

Translate
Kautuk Sahni
Harwinder-singh
New Participant
Aug 21, 2023 3:10 PM UTC

@sesmic Your second issue is most likely due to this.

 

 function getMultifieldsContent() {
        $.ajax(`${CFM.EditSession.fragment.urlBase}/jcr:content/data.2.json`)
        .done(loadContentIntoMultiFields);
    }

 

Translate
sesmic
sesmicAuthor
Level 4
Aug 23, 2023 5:48 PM UTC

Hi @harwinder-singh,
Thanks for the response. Will removing that part resolve the issue? Also, the major issue is the first one, which I want to fix somehow.

 

Translate