[AEM Sites]{class="badge positive" title="Applies to AEM Sites)."}
Defining Content Fragment Models defining-content-fragment-models
Content Fragment Models in Adobe Experience Manager (AEM) as a Cloud Service define the structure for the content of your Content Fragments. These fragments can then be used for page authoring, or as a foundation for your headless content.
This page covers how to define your content fragment model, using the dedicated editor. See Managing your Content Fragment Models for further tasks and options available once your fragments are created, including actions available from the Content Fragments Console, allowing the model on your folder and publishing your model.
- “This model has a custom UI Schema configured. The order of fields displayed in this UI may not match the UI Schema. To view the fields aligned with the UI Schema, you need to switch to the new Content Fragment Editor.”
Defining your Content Fragment Model defining-your-content-fragment-model
The Content Fragment Model effectively defines the structure of the resulting Content Fragments using a selection of Data Types. Using the model editor you can add instances of the data types, then configure them to create the required fields:
-
In the Content Fragment Console, select the panel for Content Fragment Models and navigate to the folder holding your Content Fragment model.
note NOTE You can also open a model directly after creating it. -
Open the required model for Edit; use either one of the quick action links, or select the model and then the action from the toolbar.
Once open the model editor shows:
-
top:
- Home icon
- option to toggle between the original and new editor
- Cancel
- Save
-
left: Data Types available for creating fields
-
middle: fields already defined together with the Add option
-
right: using the icons at the far right you can select between:
- Properties: define and view properties for the selected field
- Model details: show the Enabled status, Model Title, Tags, Description and Preview URL
-
-
To Add a Field
-
Either:
- Drag a data type from the left panel to the required location for a field in the middle panel.
- Select the + icon by a Data Type to add it to the bottom of the field list.
- Select Add in the middle panel and then the required data type from the resulting drop down list to add a field to the bottom of the list.
note NOTE Tab placeholder fields must always appear above existing fields. -
You can reposition a field using the formation of dots at the left of the field box:
-
Once a field has been added to the model (and is selected), the right panel shows the Properties that can be defined for that particular data type. Here you can define what is required for the specific
field.-
Many properties are self-explanatory, for additional details see Properties (Data Types).
-
Typing a Field Label auto-completes the Property Name - if empty, and it can be manually updated afterwards.
note caution CAUTION When manually updating the property Property Name for a data type, names must contain only A-Z, a-z, 0-9 and underscore “_” as special character. If models created in earlier versions of AEM contain illegal characters, remove or update those characters.
For example:
note NOTE When a field is defined as Required, the Label indicated in the middle pane is marked with an asterix (*). -
-
-
To Remove a Field
Select the trash-can icon for the appropriate field in the middle panel.
-
Add all required fields, and define the related properties, as required.
-
Select Save to persist the definition.
Data Types data-types
A selection of data types is available for defining your model:
-
Single line text
- Add a field for a single line of text; the maximum length can be defined
- The field can be configured to allow fragment authors to create new instances of the field
-
Multi line text
- A text area that can be Rich Text, Plain Text, or Markdown
- The field can be configured to allow fragment authors to create new instances of the field
note NOTE Whether the text area is Rich Text, Plain Text, or Markdown, is defined in the model by the property Default Type. This format cannot be changed from the Content Fragment editor, but only from the Model. -
Number
- Add a numerical field
- The field can be configured to allow fragment authors to create new instances of the field
-
Boolean
- Add a boolean checkbox
-
Date and time
- Add a date and/or time field
-
Enumeration
- Add a set of Checkbox, Radio Button, or Dropdown fields
- You can specify the options available to the fragment author
- Add a set of Checkbox, Radio Button, or Dropdown fields
-
Tags
- Allows fragment authors to access and select areas of tags
-
Fragment Reference
-
References other Content Fragments; can be used to create nested content
-
The data type can be configured to allow fragment authors to:
- Edit the referenced fragment directly.
- Create a new Content Fragment, based on the appropriate model
- Create new instances of the field
-
The reference specifies the path to the referenced resource; for example
/content/dam/path/to/resource
note NOTE AEM has recurrence protection for: -
Content References
This prevents the user from adding a reference to the current fragment, and may lead to an empty Fragment Reference picker dialog. -
Fragment References in GraphQL
If you create a deep query that returns multiple Content Fragments referenced by each other, it returns null on the first occurrence.
note caution CAUTION If you will be querying against multiple referenced fragments, then it is not recommended that the various fragment models have field names with the same name, but different types. For further details see AEM GraphQL API for use with Content Fragments - Limitations Content Reference content-reference
The Content Reference data type allows you to render content from another source; for example, image, page or Experience Fragment.
In addition to standard properties you can specify:
-
The Root Path, which specifies, or represents, where to store any referenced content
note NOTE This is mandatory if you want to directly upload and reference images in this field when using the Content Fragment editor. See Reference Images for further details. -
The content types that can be referenced
note NOTE These must include Image if you want to directly upload and reference images in this field when using the Content Fragment editor. See Reference Images for further details. -
Limitations for file sizes
-
If an image is referenced:
- Show Thumbnail
- Image restraints of height and width
Fragment Reference (Nested Fragments) fragment-reference-nested-fragments
The Fragment Reference data type can reference one, or more, Content Fragments. This feature is of particular interest when retrieving content for use in your app, as it allows you to retrieve structured data with multiple layers.
For example:
- A model defining details for an employee; including:
- A reference to the model that defines the employer (company)
code language-xml type EmployeeModel { name: String firstName: String company: CompanyModel } type CompanyModel { name: String street: String city: String }note NOTE Fragment References are of particular interest for Headless Content Delivery using Content Fragments with GraphQL. In addition to standard properties you can define:
-
Render As:
-
multifield - the fragment author can create multiple, individual, references
-
fragmentreference - allows the fragment author to select a single reference to a fragment
-
-
Model Type
Multiple models can be selected. When adding references to a Content Fragment, any referenced fragments must have been created using these models. -
Root Path
This specifies, or represents, a root path for any fragments referenced. -
Allow Fragment Creation
This allows the fragment author to create a fragment based on the appropriate model.
- fragmentreferencecomposite - allows the fragment author to build a composite, by selecting multiple fragments
note NOTE A recurrence protection mechanism is in place. It prohibits the user from selecting the current Content Fragment in the Fragment Reference, and may lead to an empty Fragment Reference picker dialog. There is also recurrence protection for Fragment References in GraphQL. If you create a deep query across two Content Fragments that reference each other, it returns null. -