Defining Content Fragment Models defining-content-fragment-models
Content Fragment Models in 蜜豆视频 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.
- 鈥淭his 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 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 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 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 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
-
-
Content Reference
- References other content, of any type; can be used to create nested content
- If an image is referenced, you can opt to show a thumbnail
- The field can be configured to allow fragment authors to create new instances of the field
- The reference specifies the path to the referenced resource; for example
/content/dam/path/to/resource
-
JSON Object
-
Allows the Content Fragment author to enter JSON syntax into the corresponding elements of a fragment.
- To allow AEM to store direct JSON that you have copy/pasted from another service.
- The JSON is passed through, and output as JSON in GraphQL.
- Includes JSON syntax-highlighting, auto-complete, and error-highlighting in the Content Fragment editor.
-
-
Tab placeholder
-
Allows the introduction of tabs for use when editing the Content Fragment content.
- These are shown as dividers in the model editor, separating sections of the list of content data types. Each instance represents the start of a new tab.
- In the fragment editor each instance appears as a tab.
note note NOTE This data type is purely used for formatting, it is ignored by the AEM GraphQL schema. Tab placeholder fields must always appear above existing fields.
-
Properties (Data Types) properties
Many properties are self-explanatory, for certain properties additional details are below:
-
Property Name
When manually updating this property for a data type, names must contain only A-Z, a-z, 0-9 and underscore 鈥淿鈥 as special character.
note caution CAUTION If models created in earlier versions of AEM contain illegal characters, remove or update those characters. -
Render As
The various options for realizing/rendering the field in a fragment. Often this allows you to define whether the author will see a single instance of the field, or will be allowed to create multiple instances. When Multiple Field is used you can define the minimum and maximum number of items - see Validation for further details.
-
Field Label
Entering a Field Label autogenerates a Property Name, which can then be manually updated if necessary. -
Validation
Basic validation is available by mechanisms such as the Required property. Some data types have addition validation fields. See Validation for further details. -
For the data type Multi line text it is possible to define the Default Type as either:
- Rich Text
- Markdown
- Plain Text
If not specified, the default value Rich Text is used for this field.
Changing the Default Type in a Content Fragment model will only take effect on an existing, related, Content Fragment after that fragment is opened in the editor and saved.
-
Unique
Content (for the specific field) must be unique across all Content Fragments created from the current model.This is used to ensure that content authors cannot repeat content already added in another fragment of the same model.
For example, a Single line text field called
Country
in the Content Fragment Model cannot have the valueJapan
in two dependent Content Fragments. A warning is issued when the second instance is attempted.note note NOTE Uniqueness is ensured per language root. note note NOTE Variations can have the same unique value as variations of the same fragment, but not the same value as used in any variation of other fragments. -
See Content Reference for more details about that specific data type and its properties.
-
See Fragment Reference (Nested Fragments) for more details about that specific data type and its properties.
-
Translatable
Checking the Translatable checkbox on a field in the Content Fragment Model editor will:
- Ensure the field鈥檚 property name is added to the translation configuration, context
/content/dam/<sites-configuration>
, if not already present. - For GraphQL: set a
<translatable>
property on the Content Fragment field toyes
, to allow GraphQL query filter for JSON output with only translatable content.
- Ensure the field鈥檚 property name is added to the translation configuration, context
Validation validation
Various data types now include the possibility to define validation requirements for when content is entered in the resulting fragment:
-
Single line text
- Compare against a predefined regex.
-
Number
- Check for specific values.
-
Content Reference
- Test for specific types of content.
- Only assets of specified file size or smaller can be referenced.
- Only images within a predefined range of width and/or height (in pixels) can be referenced.
-
Fragment Reference
- Test for a specific Content Fragment model.
-
Min Number of Items / Max Number of Items
Fields that have been defined as a Multiple Field (set with Render As) have the options:
- Min Number of Items
- Max Number of Items
These are validated in the Content Fragment Editor.
Using References to form Nested Content using-references-to-form-nested-content
Content Fragments can form nested content, using either of the following data types:
-
- Provides a simple reference to other content; of any type.
- Provided by the Content Reference data type
- Can be configured for one or multiple references (in the resulting fragment).
-
Fragment Reference (Nested Fragments)
-
References other fragments, dependent on the specific models specified.
-
Provided by the Fragment Reference data type
-
Allows you to include/retrieve structured data.
note note NOTE This method is of particular interest when you are using Headless Content Delivery using Content Fragments with GraphQL. * Can be configured for one or multiple references (in the resulting fragment).
-
-
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.
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 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 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)
type EmployeeModel {
name: String
firstName: String
company: CompanyModel
}
type CompanyModel {
name: String
street: String
city: String
}
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