nested navigation as json using content fragments | Community
Skip to main content
sreenu539
Level 7
April 2, 2024
Solved

nested navigation as json using content fragments

  • April 2, 2024
  • 5 replies
  • 1306 views

Hi,

 

criteria: provide navigation data as json to other front end applications.

 

Here is sample navigation I am looking to generate

 

I have below structure to generate navigation menu up to 3 levels.

Navigations structure:

  •     name (top menu item)
  •     isActive
  •     description 
  •     link (sub menu link href)
  •     linklabel (sub menu link label)

 

sub menu can have other nested sub menus.

 

How can I achieve this using content fragments ? It seems "fragment reference" only outputs the cf path rather than data of fragment referred. I do not see any "nested multifield" support for content fragments.

 

 

Thanks,

Sri

 

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 Mahedi_Sabuj

You can utilize GraphQL to read Content Fragment data, including the ability to retrieve referenced data.

query { articleList { // Article Content Fragment items { title author { // Author Content Fragment _path name } } } }

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql-api/sample-queries#sample-wknd-nested-fragment-single-model

 

5 replies

Level 2
April 2, 2024

You could create a custom endpoint at server-side to read the reference fragments data and add it in JSON response.

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
April 5, 2024

You can utilize GraphQL to read Content Fragment data, including the ability to retrieve referenced data.

query { articleList { // Article Content Fragment items { title author { // Author Content Fragment _path name } } } }

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql-api/sample-queries#sample-wknd-nested-fragment-single-model

 

Mahedi Sabuj
arunpatidar
Community Advisor
Community Advisor
April 8, 2024

Hi @sreenu539 

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.

Arun Patidar
aanchal-sikka
Community Advisor
Community Advisor
April 14, 2024

@sreenu539 

 

This would need customization. Just like Navigation Sling Model derives information from pages, we would need to derive information from CF hierarchy.

 

Other choice is to use GraphQL (preferred option), since an external application needs this data. Please review queries on: https://experienceleague.adobe.com/en/docs/experience-manager-learn/getting-started-with-aem-headless/graphql/advanced-tutorial/explore-graphql-api#query-for-all-content-at-once

 

 

Aanchal Sikka
kautuk_sahni
Community Manager
Community Manager
May 17, 2024

@sreenu539  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.

Kautuk Sahni