FAQ using Content Fragments ! | Community
Skip to main content
August 17, 2023

FAQ using Content Fragments !

  • August 17, 2023
  • 3 replies
  • 2424 views

Hello, wanted to expose FAQ content which will contain two fields only question and answers for diffrent services(AWS,MongoDB,AZURE) etc. 

So we have created proxy api pages for each services and placing the content fragments over to the pages using Content Fragment component. Now for sending the FAQs of any service as an content we can use the model.json placed after the proxy api pages , the issue we are facing is we are getting unwanted fields in generated json we just want question and answer field in generated json , is there any way to resolve this issue .

 

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
August 18, 2023

@snehra You can get only the content fragment's json from the page by directly referring the content fragment path under the page like this below

http://localhost:4502/content/we-retail/language-masters/en/manchester-airport/jcr:content/root/responsivegrid/contentfragment.model.json 

 

Is that what you are looking for? 

Please check this doc page https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/json-exporter.html?lang=en 

 

SnehRaAuthor
August 18, 2023

Hi Saravanan

consider this page for example:

Here i have dropped 2 content fragments using content fragment component as this page is made only for the QnA related to 1 service that is MONGoDB in this case so we can drop as many QnA CF here, now when I hit the URL:

localhost:4502/editor.html/content/we-retail/us/en/experience/mongodb_faqs.model.tidy.json

i get json in this format 

but i just need the values of question and answers only i dont need other values like description, itemOrder.

Somewhat I need it in below format:

json:

{QnA_1:{question:questionValue,answer:answerValue}

QnA_2:{question:questionValue,answer:anserValue}}

 

Thanks.

 

Harwinder-singh
Community Advisor
Community Advisor
August 21, 2023

@snehra , GraphQl might be the answer to the problem you are facing.

Using GraphQL, you get only what you request (question and its answer in this case)

You can check out this documentation link on how you can use GraphQl for CFs.

 

https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/graphql/multi-step/explore-graphql-api.html?lang=en

 

Preetpal_Bindra
Community Advisor
Community Advisor
August 22, 2023

We had quite a similar requirement when graphql was not around.

The way we built the solution then was to create a custom FAQ component with JSON exporter.

However, as suggested here, if you could leverage graphql that will be the best route. You won't even need the API page no more and will save the content authors some authoring steps.

If you can't, however, then you need to drill down to he content fragment node under the page to use extract only the JSOn you need without all the clutter.