These docs are for v3.5. Click to read the latest docs for v5.0.

Additional Data

How to use Additional Data in Open Content

Intro to Additional Data

Additional Data is a way to create lists of reusable data for your templates.
The Addition Data list can be managed from the Module Action Dropdown.
Example of additional data are Categories, Tags, Type etc.
Contrary to other modules there are no predefined categories or tags, you have to add them yourself.
A bit more work but very flexible.

Below we'll explain what to do when you are editing your OC files manually.
Most of this can also be done using the template builder

Steps to add Additional Data

1. Define the schema and options for your additional data.
This is the same as every other Open Content Template data by adding
[name]-schema.sjon
[name]-options.sjon
files per type of Additional Data
Where [name] is the name of the Additional Data.
Please note that the [name] of these files will be used to identify the data.

{
    "type": "array",
	"items": {
        "type": "object",
        "properties": {
            "Id": {
                "type": "string",
                "title": "Id (internal)"
            },
            "Title": {
                "type": "string",
                "title": "Category Name"
            }
        }
    }
}
{
    "items": {
        "fields": {
            "Id": {
                "type": "guid",
                "hidden": true
            },
            "Title": {
                "type": "text"
            }
        }
    }
}

This defines the data of the additional data. You need a set of these two files for every type of additional data.

2. Add an Additional Data definition to the Manifest.

You need to define the Additional Data in the manifest

{
    ...
	
    "templates": {
        ...
    },
	"additionalData": {
			"Categories": { /* This should be equal to [name] */
				"title": "Article Category",
				"scope": "module" /* tabmodule, module, tab, portal */
			}
		}

}

"title" is the Title you will see in the Module action drop-down for editing.
"scope" sets on what level the data is stored, meaning you can can limit the Categories available to the Portal, Page, or Module.

You can also set "additionalDataInTemplate": true, for a template in the manifest.
In that case the complete set of additional data is available as as separate branch for that template, not only the data that is assigned to your Items.
This can be useful when you want to show / loop over a list of all existing categories for instance. To avoid passing a very large object that's not used, this is an option that is off by default.

3. Add the Additional Data to your Main template

{
    "type": "object",
    "properties": {
			"Title": {
				"title": "Title",
				"type": "string"
			},
			"Intro": {
				"title": "Intro",
				"type": "string"
			},
			"Text": {
				"title": "Text",
				"type": "string"
			},
			"Categories": {
			  "type": "string",
			  "title": "Category (single)"
			}
		}
}
{
	"fields": {
		"Intro": {
			"title": "Introduction",
			"type": "textarea"
		},
		"Text": {
			"title": "Text",
			"type": "ckeditor"
		},
		 "Category": {
		  "type": "select2",
		  "dataService": {
			"action": "LookupData",
			"data": {
			  "dataKey": "Categories",
			  "valueField": "Id",
			  "textField": "Title"
			}
		  }
		}
	}
}

This way you should be able to add and edit "Categories" from the Module action menu and assign them to your items.
When you want the your Additional Data to be available as Multi Select (multiple categories) the only thing you need to do is; change the "type" in this schema from "array" to "string". (and probably change the Titles from Category to Categories)