Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Build breadcrumb using content fragment references.

Avatar

Level 3

I have a content fragment A which is referencing content fragment B and B is referencing  content fragment C.

I want to build a breadcrumb from the content fragment references. For example:

when I select a content fragment C, I should be able to see its content hierarchy in the form of breadcrumb  A/B/C.

Do we any OOTB feature which can give us the content fragment reference hierarchy. If not what can be the possible ways to achieve this?

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Level 4

There is no out-of-the-box (OOTB) feature in AEM that allows you to easily build a breadcrumb from the content fragment references. However, there are a few ways you could approach this problem:

  1. You could write a custom servlet or service that retrieves the content fragment references and builds the breadcrumb string. You could then invoke this service from your content fragment component or from a client-side script to display the breadcrumb.

  2. You could use the AEM Query Builder to retrieve the content fragment references and build the breadcrumb string. You could use it to find the content fragment references and build the breadcrumb string using the results.

  3. You could use the AEM GraphQL API to retrieve the content fragment references and build the breadcrumb string. You could use it to retrieve the content fragment references and build the breadcrumb string using the results.

Ultimately, the approach you choose will depend on your specific requirements and the tools and resources available to you. You may want to consider factors such as the complexity of the solution, the performance and scalability needs of your application, and the skills and expertise of your team.

View solution in original post

5 Replies

Avatar

Employee Advisor

@ravir73578276 
Not sure how would you navigate through these content fragment references to build breadcrumb. Also, there is no OOTB feature available as such, however you can create your own custom Breadcrumb component, where in on selection of a content fragment it can trace the references and can build the hierarchy until root. Also, you might have to enforce that a Content Fragment should not have more than one reference. 

 

Avatar

Community Advisor

Hi @ravir73578276 

You can achieve this using the custom logic by taking the root CF and navigating to the references until the depth required.

This is may some performance impact as your trying to get the CF referenced and this implementation is recursive.

 

Avatar

Community Advisor

Hello @ravir73578276 

 

Noticed that you have also marked your question for GraphQL API.

Are you trying to create a breadcrumb on an AEM Site or fetching this info to be accessed via GraphQL?


Aanchal Sikka

Avatar

Level 3

Right, I have the requirement to fetch this data via Graphql.

Avatar

Correct answer by
Level 4

There is no out-of-the-box (OOTB) feature in AEM that allows you to easily build a breadcrumb from the content fragment references. However, there are a few ways you could approach this problem:

  1. You could write a custom servlet or service that retrieves the content fragment references and builds the breadcrumb string. You could then invoke this service from your content fragment component or from a client-side script to display the breadcrumb.

  2. You could use the AEM Query Builder to retrieve the content fragment references and build the breadcrumb string. You could use it to find the content fragment references and build the breadcrumb string using the results.

  3. You could use the AEM GraphQL API to retrieve the content fragment references and build the breadcrumb string. You could use it to retrieve the content fragment references and build the breadcrumb string using the results.

Ultimately, the approach you choose will depend on your specific requirements and the tools and resources available to you. You may want to consider factors such as the complexity of the solution, the performance and scalability needs of your application, and the skills and expertise of your team.