Using a content fragment field in another field of the same content fragment in AEM | Community
Skip to main content
May 11, 2024
Question

Using a content fragment field in another field of the same content fragment in AEM

  • May 11, 2024
  • 1 reply
  • 584 views

Is it possible to content fragment fields in other fields of the same content fragment? For example...

Lets say I have a content fragment that has a field called formalName and shortName. These are basic text fields. In the same content fragment I provide an author a text area with RTE capabilities. They would like to enter text that says something like "The topic of this article is [shortName]." This would account for the possibility that the shortName or formalName could be updated at any time and should be able to be easily updated rather than having to manually search for usage.

 

Is this possible or is there a different approach that should be considered?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

sarav_prakash
Community Advisor
Community Advisor
May 12, 2024

Ask sounds valid to Reuse Content. By templating fields, you want to reuse content from [shortName] into say [topicSummary]. But such templating, we do at presentation layer rather than author. Say this content fragment is exposed as GraphQL or used in Headful AEM component, at presentation layer(Head or HTL), you template and present different fields.

 

If ask is at author itself, mostly should be Content Duplication. So we write a EventListener that listens to content fragment edits. Whenever the fragment is edited, the [shortName] value should be duplicated into [topicSummary] field by replacing templated string of RTE. If you are in AEMaaCS, adobe recommends to use Auto-start workflows. Here is an example how to do - https://medium.com/@bsaravanaprakash/aem-assets-post-processing-workflows-a-savior-to-resource-change-hell-problem-da59d6aebfe4