Expand my Community achievements bar.

SOLVED

nested navigation as json using content fragments

Avatar

Level 7

Hi,

 

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

 

Here is sample navigation I am looking to generate

sreenu539_0-1712098483866.png

sreenu539_1-1712098590016.png

 

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

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

 

View solution in original post

5 Replies

Avatar

Level 2

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

Avatar

Correct answer by
Community Advisor

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

 

Avatar

Community Advisor

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

Avatar

Community Advisor

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

 

 


Aanchal Sikka

Avatar

Administrator

@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