Tech Insights
AEM Content Fragments: Content Structure
In this article we will show you how to prepare CFs’ structure and translation configuration.
Content Structure
There are no restrictrictions where you can store content fragments in AEM. Originally, you would store them in /content/dam/site-com’ (the We Retail site has this type of structure, for example). This might be not handy if your site folder has a lot of subfolders, and having several folders for every language would create a mess.
To create the language root, you create a folder and use an ISO language code as a name. The language code must be in one of the following formats:
- <language-code> The supported language code is a two-letter code as defined by ISO-639-1 (like en).
- <language-code>_<country-code> or <language-code>-<country-code> The supported country code is a lower-case or upper-case two-letter code as defined by ISO 3166, such as en_US, en_us, en_GB, en-gb.
AEM will determine where the language root is automatically. You can have a separate folder for CFs just for your comfort. This approach might be particularly handy if you want to configure quick access to the CFs folder from Navigation (this will be explained below).
Our content fragments are stored under ‘/content/dam/site-com/content-fragments’.
Here’s the content structure for them:
/en serves as a blueprint.
We use on-deploy scripts so we don’t have to create it manually (this feature is not AEM as a Cloud Service compatible; starting with the 4.6.2 release, this feature is disabled on this platform, including the SDK.):
Now, we can create a language copy. This will just copy the content; translation will be set up later.
Let’s say we have a content fragment in a blueprint folder: ‘/content/dam/site-com/content-fragments/en/myfirstcf/test-cf’. Select this CF and click References on the left:
As you can see, only one language copy exists now. To create a French version, click ‘Create and Translate:’
After that you’ll see that a French CF was created:
CF Quick Access
We will start by setting up quick access to our Content Fragments in AEM by adding them to Navigation. This is a quick fix; just add a new item under /apps/cq/core/content/nav.
A new item is available in Navigation:
Global Link Translation Setup
Adobe recommends using the Translation Integration Framework to manage the localization of your data. The Translation Integration Framework integrates with third-party translation services to orchestrate the translation of AEM content. To use it:
- Connect to your translation service provider
- Create a Translation Integration Framework configuration
- Associate the cloud configurations with your pages/assets
We are using Global Link (v5.9.8) as a translation service provider. This version does not provide an implementation of the new API for translation projects, so we have to use the Global Link admin console and set up configuration for GL itself.
To set up a translation in GL, we need to create a new repository for it.
Adding the .xml config is enough:
/libs/globallink-adaptor/config/repositories/content/dam/site-com/content-fragments/.content.xml:
The property that we’re interested in is ‘damAssetProperties=“[title,dc:title,description]”’, which is where we list the properties in the CF available for translation.
Update Asset Workflow Change
Since a content fragment is technically an asset (since it has type dam:Asset), we need to prevent ‘Update DAM Asset workflow’ from applying to them.
/conf/global/settings/workflow/models/dam/update_asset/.content.xml
We need to add a new process config in the beginning of the <flow> section:
And a corresponding process
com.wcm.site.workflow.CFDamUpdateGateKeeperProcess:
This quick look at CF content structure and initial set up will get you started. As our content fragment series continues, we’ll continue to take a deeper dive into working with CF.
Author: Iryna Ason