The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.
A model definition, a subitem of the Magnolia Content type definition, defines the model of a content type.
The Magnolia Content Types module is currently available as a Developer Preview. Development for the first official release is still underway.
This developer preview brings several powerful features. Please try it out and feel free to send us your feedback and suggestions based on your experience.
We are working to finalize the module as soon as possible.
The model describes the properties of a content item such as name, description, asset, birthday, and so on. In the default JCR-based implementation. The type of the properties can be String
, Boolean
, Decimal
, Double
, Long
, Date
, another content type or a submodel. The model can define a list of submodel definitions.
Model definition properties
Example configuration:
datasource: workspace: tourguides namespaces: mt: https://www.magnolia-travel.com/jcr/1.0/mt autoCreate: true model: nodeType: mt:tourGuide properties: - name: birthday type: Date - name: gender - name: shortBio - name: contact type: contactData subModels: - name: contactData properties: - name: email - name: phoneNumber - name: addresses type: address multiple: true - name: address properties: - name: street - name: city - name: postalCode - name: country
model
properties:properties | required A list of property definition objects. |
| A subdefinition item defining one property of the model. Its definition interface is PropertyDefinition. Read the property definition properties section for all the details of a PropertyDefinition object. |
subModels | optional A list of submodel definition objects. |
| A subdefinition item configuring a complete submodel. Its definition interface is SubModelDefinition. A submodel has the same properties as a model, but a submodel cannot have additional submodels. If |
nodeType | optional The name of the JCR node type for storing an item of the given content type. If the given node type has not been registered yet, the system automatically registers a new node type by the given name. The type generated inherits from the Magnolia If |
Property definition properties
This section describes the PropertyDefinition definition item. Property definition items can be defined in the properties
property, which is a property of the model definition of a content type definition.
<property> | |
---|---|
| required The name of the property. The name is used for storing values in the underlying data source. |
| optional, default is Possible values:
|
| optional, default is Makes the property mandatory. |
| optional, default is Enables i18n support for the property. |
| optional, default is The |
Submodels
Use submodels to define complex content types . Submodels are useful whenever you need a group of fields more than once. A content type model definition can contain a list of submodel definitions within the subModels
property. Submodels can be used only within the content type where they have been defined.
A submodel definition has the same properties as a model, but a submodel cannot have additional submodels.
Interfaces and classes
Model
The base interface is ModelDefinition.
Magnolia provides the JcrDataSourceDefinition interface and the ConfiguredJcrModelDefinition implementation class to specify the model to be mapped to a JCR node.
For ModelDefinition, the ConfiguredJcrModelDefinition is set as the default implementation class via type mapping on the XML-based module descriptor of the magnolia-content-types
module.
By default, Magnolia expects you to configure properties for JcrModelDefinition to define a model.
Submodel
The submodel item is defined by the SubModelDefinition interface, which extends ModelDefinition. The default implementation is ConfiguredJcrSubModelDefinition.
By default, Magnolia expects you to configure properties for ConfiguredJcrSubModelDefinition to define a submodel.