AEM Content Fragment Models define content schemas which can be used to templatize the creation of raw content by AEM authors. This approach is similar to scaffolding or forms-based authoring. The key concept with Content Fragments, is the authored content is presentation-agnostic, meaning its intended for multi-channel use where the consuming application, be that AEM, a single page application, or a Mobile app, controls how the content is displayed to the user.
The primary concern of the Content Fragment is to ensure:
This chapter covers enabling and defining Content Fragment Models used to define a normalized data structure and authoring interface for modeling and creating “Events”.
Content Fragment Models must be enabled via AEM’s Configuration Browser.
If Content Fragment Models are not enabled for a configuration, the Create > Content Fragment button will not appear for the relevant AEM configuration.
AEM’s configurations represent a set of context-aware tenant configurations stored under /conf
. Typically AEM configurations correlate with a particular Web site managed in AEM Sites or a business unit responsible for a sub-set of content (assets, pages, etc.) in AEM.
In order for a configuration to affect a content hierarchy, the configuration must be referenced via the cq:conf
property on that content hierarchy. (This is achieved for the WKND Mobile configuration in Step 5 below).
When the global
configuration is used, the configuration applies to all content, and cq:conf
does not need to be set.
See the Configuration Browser documentation for more information.
Log in to AEM Author as a user with appropriate permissions to modify the relevant configuration.
Navigate to Tool > General > Configuration Browser
Tap the folder icon next to WKND Mobile to select, and then tap the Edit button in the top left.
Select Content Fragment Models, and tap Save & Close in the top right.
This enables of Content Fragment Models on Asset Folder content trees that have the WKND Mobile configuration applied.
This configuration change is not reversible from the AEM Configuration Web UI. To undo this configuration:
1. Open [CRXDE Lite](http://localhost:4502/crx/de)
1. Navigate to `/conf/wknd-mobile/settings/dam/cfm`
1. Delete the `models` node
Any existing Content Fragment Models created under this configuration will be deleted as well as their definitions are stored under /conf/wknd-mobile/settings/dam/cfm/models
.
Apply the WKND Mobile configuration to the WKND Mobile Assets Folder to allow Content Fragments from Content Fragment Models to be created within that Assets folder hierarchy:
Before defining out Content Fragment model, let’s review the experience we’ll be driving to ensure we are capturing all the necessary data points. For this, we’ll review out Mobile applications design and map the design elements to content-to-collect.
We can break out the data points that define an Event as follows:
Armed with the mapping we can define out Content Fragment that will be used to collect and ultimately expose the Event data.
Navigate to Tools > Assets > Content Fragment Models > WKND.
Select the Event Content Fragment Model and tap Edit in the top action bar.
From the Data Types tab on the right, drag the Single line text input into the left drop-zone to define the Question field.
Ensure the new Single line text input is selected on the left, and the Properties tab is selected on the right. Populate the Properties fields as follows:
textfield
Event Title
eventTitle
Yes
Repeat these steps using the input definitions defined below to create the rest of the Event Content Fragment Model.
The Property Name fields MUST match exactly, as the Android application is programmed to key off these names.
Multi-line text
Event Description
eventDescription
Rich text
Date and time
Event Date and Time
eventDateAndTime
Yes
Enumeration
Event Type
eventType
Art,Music,Performance,Photography
Number
numberfield
Ticket Price
eventPrice
Integer
Yes
Content Reference
contentreference
Event Image
eventImage
/content/dam/wknd-mobile/images
Yes
Single-line text
textfield
Venue Name
venueName
Yes
Enumeration
Venue City
venueCity
Basel,London,Los Angeles,Paris,New York,Tokyo
The Property Name denotes the both the JCR property name where this value will be stored as well as the key in the JSON file . This should be a semantic name that is will not change over the life of the Content Fragment Model.
After completing creating of the Content Fragment Model, you should end up with a definition that looks like:
Optionally, install the com.adobe.aem.guides.wknd-mobile.content.chapter-2.zip content package on AEM Author via AEM’s Package Manager. This package contains the configurations and content outlined in this part of the tutorial.