You can customize the Content Editor interface with JSON overrides. This topic shows you how override sections, fieldsets, and fields.
This section shows how to define static forms, how Jahia applies inheritance to sections, and provides an example of applying section overrides.
You can override the static definition of the forms and fieldsets by adding JSON files in the META-INF/jahia-content-editor-forms
folder of your Jahia module, and then in the forms
or fieldsets
subdirectory. The files should have meaningful names and to ensure consistency between your definitions and your overrides. We recommend replacing the colon (:) between the namespace and the content type with an underscore. For example, the override of the qant:myFields
node type should be named qant_myFields.json
.
Here's an example of a JSON static form definition:
{
"nodeType": "qant:myFields",
"priority": 1.0,
"sections": [
{
"name": "layout"
}
]
}
With this definition, when you create or edit a node of the type qant:myFields
, a form with a section named layout displays.
Other examples can be found in our Content Editor test folder.
By default, you can redefine all properties available in the JSON override:
Jahia applies inheritance in the following way:
You can use JSON overrides to define the section and preview behavior for a form. This example shows how to perform section and preview overrides of the jnt:content
content definition and how to disable preview for the qant:myFieldsRequired
content type.
With form overrides, you can define the sections and preview behavior for a nodetype such as jnt:content
.
[qant:myFieldsRequired] > jnt:content, qamix:qaContent, jmix:editorialContent
- sharedSmallText (string) mandatory
- smallText (string) i18n mandatory
First, provide a JSON form definition for jnt:content that:
The JSON override (added to /your_module/src/main/resources/META-INF/jahia-content-editor-forms/forms/jnt_content.json
) is:
{
"nodeType": "jnt:content",
"priority": 1.0,
"hasPreview": true,
"sections": [
{
"name": "content",
"labelKey": "label.engineTab.content",
"requiredPermission": "viewContentTab"
},
{
"name": "metadata",
"labelKey": "label.engineTab.metadata",
"requiredPermission": "viewMetadataTab"
}
]
}
This creates a global rule and JSON override for jnt:content
that is the default structure for all jnt:content
and every node type that inherits from jnt:content
.
But you would like to disable the preview for the qant:myFieldsRequired
content type. You can override only hasPreview
in a separate JSON override for qant:myFieldsRequired
because, at the end, JSON overrides are merged together.
Here is the additional JSON override (added to /your_module/src/main/resources/META-INF/jahia-content-editor-forms/forms/qant_myFieldsRequired.json
) to override qant:myFieldsRequired
.
{
"nodeType": "qant:myFieldsRequired",
"priority": 1.0,
"hasPreview": false
}
This way, only qant:myFieldsRequired will have preview disabled and all other jnt:content will have the preview enabled.
Fieldset overrides allow you to add a new fieldset or edit fields within an existing fieldset. This sections explains how you can manipulate fields in fieldsets or sections. The next section shows you how to manipulate fields.
Fieldset overrides are JSON files that are stored in the following directory:
/your_module/src/main/resources/META-INF/jahia-content-editor-forms/fieldsets
The JSON file has the following format:
{
"name": "jmix:myType",
"fields": ...
...
}
The Form builder builds forms from the definition. Then, for each inherited type the builder merges the current form with the overrides that match each type, according to their priority.
For example, for page content the Form builder:
The following properties define a fieldset:
The section describes field overrides, lists field properties that you can override, and provides examples of field overrides.
JSON overrides can override existing fields or add new fields. You can define field overrides in the fields section of fieldset override. The override applies to the node type defined by the name property of the fieldset.
{
"name": "jmix:myType",
"fields": [
{
"name": "fieldName",
"mandatory": false,
...
}
}
Here the properties that can be overridden or used to create a field:
Extensions are global to the platform. There is no need to enable the module on a site.
Currently only the direct properties of a type can have their fields overridden. It is not possible to override a field brought by a mixin on a specific type.
The properties multiple and I18n can not be overridden by json definition. As the definition does not allow to have multiple values or internationalized values, there will be an error when you will try to save the data in the JCR.
Field has a target property that allows you to move fields. You move fields by defining the section, fieldset, and ranking.
You can move a field to a given target, The target format is:
The following override moves the template name field above the other fields in a page.
{
"name": "jnt:page",
"priority": 1.1,
"fields": [
{
"name": "j:templateName",
"target": {
"rank": -1
}
}]
}