Expand my Community achievements bar.

Custom Content Fragment Component

Avatar

Level 2

Hello,

 

Goal: To display content from a content fragment onto a page or experience fragment. This must include data from fragment reference fields ie: nested content fragments and content reference fields, specifically images. Currently, OOTB only displays either with their respective paths. 

 

My Approach:

  • Create a copy of the content fragment component
  • Create a Sling Model that exposes the input values from the dialog box
    • For text fields, I would like to grab them, maybe add some basic logic and expose it to the component's HTL
    • For nested content fragments, I would like to find the content fragment, grab it's data and expose it to the component's HTL
    • For images, I would like to do the same and make it available for HTL to grab in a way that it can then display it on the page.
  • Create custom HTL for the component that displays all the content based on whether or not they are selected in the dialog box
  • Style said component with CSS

 

My issue is with the Sling Model and HTL, I am not sure how to write it in a way that satisfies my requirements. I have been able to grab the content fragment path and access the values from the content fragment but this isnt based on what has been entered in the dialog box, rather it grabs it directly from the content fragment (I think I need to add this logic in the HTL but I am not sure)

 

Any help would be highly appreciated 

Topics

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

3 Replies

Avatar

Level 2

Screenshot 2025-03-31 at 10.38.15 AM.png

Screenshot 2025-03-31 at 10.38.25 AM.png

Screenshot 2025-03-31 at 10.38.48 AM.png

  

Avatar

Administrator

@bruce_fernandes Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!



Kautuk Sahni

Avatar

Level 8

For nested content fragments, I would like to find the content fragment, grab it's data and expose it to the component's HTL

I think you may find useful this thread.