Reusing Authored Content Effectively with Contextual Content Variables for Adobe Experience Manager

August 11, 2021
blog image for Reusing Authored Content Effectively with Contextual Content Variables for Adobe Experience Manager

Adobe Experience Manager (AEM) provides non-technical users with a lot of power and flexibility when creating content as well as supplying tools for significant content reuse, like Content Fragments, but there are still situations in which developers need to be brought in to handle specific requirements. One of those cases is when content needs to be authored on a specific page but also surface values that are authored elsewhere in AEM.

Bounteous is always looking for ways to enable our partners using AEM to be self-sufficient and empowered in their authoring environment and so Contextual Content Variables, a newly released feature in Adobe Consulting Services (ACS) AEM Commons, seeks to solve this need for direct developer intervention when trying to surface a contextual variable inside authored content.

Contextual Content Variables

This new feature allows authors to use a specific token syntax that references variables stored elsewhere in the repository directly in the content they are authoring. By default, the feature comes preloaded with the following:

  • Aggregated properties from the current page
  • Aggregated inherited properties from pages above the current page in the content tree
  • The option to have the replaced value URL encoded

Here are a few examples of how the authored vs. rendered values will appear to authors and users of the site:

Authored value rendered value
The title of this page is ((page_properties.pageTitle)) and that's great! The title of this page is Home Page and that's great!
/content/myproject/en/page.html?source=((inherited_page_properties.sourceId!url)) /content/myproject/en/page.html?source=my%20source%20id


The tool is most useful when thinking of content reuse. When there is a case for shared content across multiple pages, locales, or languages that needs a little bit of context-specific information, this is the optimal solution. It will allow authors to reuse content and manage it in a single place while still providing their users with tailored experiences.

Whether the reusable content is stored in a referenced Content Fragment, at the editable template level, or even inherited from a blueprint in an MSM setup, this tool will allow for contextual content to be surfaced to users with minimal duplication of effort from the content authoring team.

How Does It Work?

The tool works on multiple content types to perform replacements on the output when there is a content variable present. It can replace values on HTML and JSON outputs, enabling this feature for use with "standard" AEM implementations that will render as HTML as well as headless implementations relying on JSON provided by AEM for the content.

The first is an HTML Transformer that will replace any tokens in the rendered HTML at runtime. This method has the added benefit of enabling the caching of the page entirely while still housing dynamic content. The replacement logic only runs when the page is initially rendered, there is no additional processing needed after the page has been rendered.

The second content type supported is JSON rendering. If enabled, the default behavior of the tool will be to replace the tokens present in the JSON exported by a Sling Model (think .model.json requests) but is configurable to support additional JSON endpoints at your discretion.

New Possibilities With Contextual Content Variables

Every site developed in AEM will have unique capabilities and a unique set of content. Knowing that the default properties available will not satisfy every customer’s use case, the tool was built with extension in mind. Both the aggregated variables and actions able to be applied to the content are extensible by a developer by following the simple steps outlined in the ACS Commons documentation.

New possibilities open up when this tool is customized for your specific use cases—it’s live now, so go and try it out!