Content Modeling Cookbook
Getting Started
To get started with Content Modeling, please visit the Content Modeling Page.
Code Samples
Here are some code samples of common data structures to help you get started.
Array of strings
An array of strings.
Definition:
"prop1": {
"type": "array",
"items": {
"type": "string"
}
}
Form:
"prop1": {
"type": "array",
"items": {
"type": "text"
}
}
An Object
An object with two properties.
Definition:
"articleAvailability": {
"type": "object",
"properties": {
"availableOnHomepage": {
"type": "boolean",
"title": "Manage this content's availability on the website home page"
},
"displayOrder": {
"type": "integer",
"title": "Display Order",
"default": 1,
"minimum": 0
}
}
}
Form:
"articleAvailability": {
"type": "object",
"fields": {
"availableOnHomepage": {
"type": "checkbox",
"label": "",
"rightLabel": "Available on Home Page?"
},
"displayOrder": {
"type": "number",
"minimum": 0,
"title": "Display Order",
"default": 1
}
}
}
The resulting JSON will look something like this:
"articleAvailability": {
"availableOnHomepage": true,
"displayOrder": 3
}
An Object Array
Model an array of objects.
Definition:
"messages": {
"type": "array",
"title": "Flags",
"items": {
"type": "object",
"title": "Flag",
"properties": {
"text": {
"title": "Text",
"type": "string",
"required": true
},
"color": {
"title": "Color",
"type": "string",
"enum": [
"notification",
"warning",
"danger"
],
"default": "notification",
"required": true
}
}
}
}
Form:
"messages": {
"type": "array",
"label": "Messages",
"toolbarSticky": true,
"items": {
"type": "object",
"label": "Message",
"fields": {
"text": {
"type": "textarea",
"label": "Text",
"required": true
},
"color": {
"type": "radio",
"default": "notification",
"rightLabel": "Color",
"label": "",
"optionLabels": [
"Notification",
"Warning",
"Danger"
]
}
}
}
}
The resulting JSON will look something like this:
"articleAvailability": {
"availableOnHomepage": true,
"displayOrder": 3
}
Related Documents
In this example we use a custom association type but the default system association type (a:linked
) would work as well. Using a custom association adds more meaning to the relationship between the node being worked on by the user and the documents it relates to.
Relator properties are always either an object or an array of objects.
Definition:
"fundDisclosureDocuments": {
"title": "List of Documents",
"type": "array",
"required": false,
"items": {
"type": "object"
},
"_relator": {
"associationType": "my-company:fund-document-association",
"nodeType": "n:node"
}
}
Form:
"fundDisclosureDocuments": {
"type": "related-content",
"label": "Documents",
"uploadPath": "/documents/funds",
"fileTypes": "(\\.|/)(pdf|docx?)$"
}
Related Image
Definition:
"articleImage": {
"type": "object",
"label": "Image",
"required": true,
"_relator":{}
}
Form:
"articleImage": {
"type": "related-content",
"label": "Image",
"required": true,
"uploadPath": "/images",
"maxNumberOfFiles": 1
}