Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

FAQ using Content Fragments !

Avatar

Level 1

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.

4 Replies

Avatar

Community Advisor

@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/resp... 

 

Is that what you are looking for? 

Please check this doc page https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/json-exporter.ht... 

 

Avatar

Level 1

Hi Saravanan

consider this page for example:

SnehRa_0-1692355931663.png

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 

SnehRa_1-1692356268022.png

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.

 

Avatar

Community Advisor

@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/g...

 

Avatar

Community Advisor

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.