Level 2
March 31, 2025
Question
Custom Content Fragment Component
- March 31, 2025
- 3 replies
- 572 views
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