Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Dynamically adding an existing content fragment to a custom component

Avatar

Level 1

I've been tasked with adding an existing content fragment to a custom component. The path to the content fragment is populated by a custom page property a content author would add. I need to use that value in a custom component that includes the dynamic call to the content fragment. All I can find in the way of examples is adding a content fragment directly to a page. Does anyone have an idea of where I can get examples of how this is done? Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi @gfuller-crescendo 

You could make use of the Sling model of the custom component.

1.) Resolve the CF using the path retrieved from page properties (authored).

2.) Use CF API to adapt to the content fragment.

3.) Set the Sling model object with values that can be read on HTL

you can refer to this one

https://aem4beginner.blogspot.com/fetch-content-fragment-using-sling-model 

 

Alternatively, if it's a front-end-based logic then you can make use of HTTP Asset API to fetch the CF details in JSON format and bind it to the UI at Front-end.

https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/assets-api-content-fr...

 

Regards,

Nitesh

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Hi @gfuller-crescendo 

You could make use of the Sling model of the custom component.

1.) Resolve the CF using the path retrieved from page properties (authored).

2.) Use CF API to adapt to the content fragment.

3.) Set the Sling model object with values that can be read on HTL

you can refer to this one

https://aem4beginner.blogspot.com/fetch-content-fragment-using-sling-model 

 

Alternatively, if it's a front-end-based logic then you can make use of HTTP Asset API to fetch the CF details in JSON format and bind it to the UI at Front-end.

https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/assets-api-content-fr...

 

Regards,

Nitesh