Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. JCR workspace
  2. JCR nodetype
    This node type inherits from the Magnolia node type mgnl:content. To define more sophisticated node types, you can create a node type definition file in a light module
  3. JCR namespace

Example

gitcmsuserscmeier/repos/content-type-examples/raw/contentTypes/tourGuide.yaml?at=master
Code Pro
profilebitbucket-cmeier-repo
languageyml
sections%%datasource%% - %%shortBio%%
url
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
Bestpractice

If a node type inheriting from mgnl:content complies with your requirements, we recommend defining all of the items – namespace, node type and workspace in the content type definition, all in one file.

...

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

    bitbucket-cmeier-repogitcms/users/cmeier/repos/content-type-examples/raw/jcr-node-type-files/travellers-node-types.xml?at=master
    Code Pro
    profile
    languagexml
    title/content-type-examples/jcr-node-type-files/travellers-node-types.xmlurl
    <?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:

    bitbucket-cmeier-reporaw/contentTypes/happyCustomer.yaml?at=master
    Code Pro
    profile
    https://git.magnolia-cms.com/users/cmeier/repos/
    languageyml
    title/content-type-examples/contentTypes/happyCustomer.yaml
    linenumberstrueurl
    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.

...