Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCU-2700

...

alignright
classmenu

A model definition, a subitem of the Magnolia Content type definition, defines the model of a content type.includeDOCS60:_content types developer preview short infoDOCS60:_content types developer preview short info

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.

...

Example configuration:

profilegitcmsuserscmeier/repos/content-type-examples/raw/contentTypes/tourGuide.yaml?at=master
Code Pro
bitbucket-cmeier-repolanguageyml
title/content-type-examples/contentTypes/tourGuide.yamlurl
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

The model properties:

properties

Anchor
anc-model-properties-list
anc-model-properties-list
required

A list of property definition objects.

<property>

A subdefinition item defining one property of the model. Its definition interface is

Javadoc resource link
classNameinfo.magnolia.types.model.PropertyDefinition
renderTypeasynchronous
version1.0
.

Read the property definition properties section for all the details of a PropertyDefinition object.

subModels

Anchor
anc-submodels-property
anc-submodels-property
optional

A list of submodel definition objects.

<submodel>

A subdefinition item configuring a complete submodel. Its definition interface is

Javadoc resource link
classNameinfo.magnolia.types.model.SubModelDefinition
renderTypeasynchronous
.

A submodel has the same properties as a model, but a submodel cannot have additional submodels.

Anchor
anc-submodel-nodeType-property
anc-submodel-nodeType-property
If nodeType is not provided, the mgnl:contentNode is used by default.

nodeType

Anchor
anc-nodeType-property
anc-nodeType-property
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 mgnl:content node type.

If nodeType is not provided, mgnl:content is used by default.

...

This section describes the 

Javadoc resource link
classNameinfo.magnolia.types.model.PropertyDefinition
renderTypeasynchronous
 definition item
version1.0
 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>

name

required

The name of the property. The name is used for storing values in the underlying data source.

type

optional, default is String

Possible values:

  • JCR property types
    • String
    • Boolean
    • Decimal
    • Double
    • Long
    • Date
  • asset - creates Link field to choose an asset.
    The name of a Submodel.
    (warning) You can only reference submodels defined in the same content type.
  • The name of Content type making a reference to another content item.
    If a submodel and a content type have the same name, the submodel takes precedence over the content type.

required

optional, default is false

Makes the property mandatory.

i18n

optional, default is false

Enables i18n support for the property.

multiple

optional, default is false

The true setting allows storing multiple values of the property.

Hide block

Not yet implemented:

<property>

label

optional

A label which is used in the UIs, fo example in a content app. The property is annotated with

Javadoc resource link
classNameinfo.magnolia.i18nsystem.I18nText
renderTypeasynchronous
, and therefore it can be localized.

defaultValue

optional

Defines the default value for the property. It is applied when creating instances.

readOnly

optional, default is false

Determines whether the property can be changed.

...

Use submodels to define complex  content types .

Multiexcerpt
MultiExcerptNamesubmodels-introduction

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.

Info

A submodel definition has the same properties as a model, but a submodel cannot have additional submodels.

The default nodeType  for a submodels is mgnl:contentNode .

Interfaces and classes

Model

...

For 

Javadoc resource link
classNameinfo.magnolia.types.model.ModelDefinition
renderTypeasynchronous
, the 
Javadoc resource link
classNameinfo.magnolia.types.model.jcr.ConfiguredJcrModelDefinition
renderTypeasynchronous
 is set as the default implementation class via type mapping on the XML-based module descriptor of the magnolia-content-types module. 

...