Versions Compared

Key

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

...

clearboth
width343px
alignright
classmenu

This page provides an overview of all ways to define custom JCR node types and create new workspaces with Magnolia.

...

  1. Create an XML-based node type definition file in your light module:

    Code Pro
    languagexml
    title/content-type-examples/jcr-node-type-files/travellers-node-types.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <nodeTypes
        xmlns:mgnl="http://www.magnolia.info/jcr/mgnl"
        xmlns:mt="https://www.magnolia-travel.com/jcr/1.0/mt">
      <nodeType name="mt:traveller" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
        <supertypes>
          <supertype>mgnl:content</supertype>
        </supertypes>
      </nodeType>
      <nodeType name="mt:tourGuide" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
        <supertypes>
          <supertype>mt:traveller</supertype>
        </supertypes>
      </nodeType>
      <nodeType name="mt:happyCustomer" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
        <supertypes>
          <supertype>mt:traveller</supertype>
        </supertypes>
      </nodeType>
    </nodeTypes>
  2. Reference the node type definition from a content type definition:

    Code Pro
    languageyml
    title/content-type-examples/contentTypes/happyCustomer.yaml
    linenumberstrue
    datasource:
      workspace: happycustomers
      autoCreate: true
      nodeTypeDefinition: /content-type-examples/jcr-node-type-files/travellers-node-types.xml
     
    model:
      nodeType: mt:happyCustomer
      properties:
        - name: country
        - name: age
          type: Double

    Line 4: References the node type definition resource via nodeTypeDefinition.

...