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

Include Content Fragment with HTL

Avatar

Level 3

We have multiple reps and for each rep we will have a bio that we are storing in content fragments. I want to include this bio on an AEM page based on a passed-in value. Each content fragment will be named according to a unique rep value, like a rep number.

For instance, the path would be something like /path/to/content/fragment/data/12345/master... where “12345” would be dynamic.

Is there a way to include the content fragment data within a custom component with HTL using something like data-sly-include or data-sly-resource or do I need to use JSON?

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @JonMaguire,

Yes it's possible to include content fragment inside custom component using HTL. Please have a look into Content Fragment component form Core Components, which is a good example how this can be done:

Simply explore above implementation and adapt it to your specific use case.

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @JonMaguire,

Yes it's possible to include content fragment inside custom component using HTL. Please have a look into Content Fragment component form Core Components, which is a good example how this can be done:

Simply explore above implementation and adapt it to your specific use case.

 

Avatar

Level 3

Thanks, @lukasz-m for the quick reply.

 

So, it’s a little more involved than just adding an include, then. It’s more of a case of adding code in a similar way to the core CF component?

 

Thanks again for the insight.