Expand my Community achievements bar.

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

Avatar

Level 1

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?

 

 

1 Reply

Avatar

Level 6

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-chang...