Include Content Fragment with HTL | Community
Skip to main content
JonMaguire
Level 3
August 5, 2022
Solved

Include Content Fragment with HTL

  • August 5, 2022
  • 1 reply
  • 883 views

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?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

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.

 

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
August 5, 2022

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.

 

JonMaguire
Level 3
August 5, 2022

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.