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

Template Settings

Open Content Template Settings

About Template settings in Open Content

Some times you want a setting for a template, that can be set outside the normal Edit screen.
This can be used to add options to a Template, anything from color variations to a switch to change the rendering of the template layout.
When you add a setting to a template, the user will first be presented with an "Edit Template Settings" screen after choosing a template and before the content can be edited.

You can use all the Field types for Template settings, making Open Content templates even more flexible.

Adding Template settings in Open Content

Template settings can be defined by adding the "[name]-schema.json" and "[name]-options.json" files.
In these files you define the fields as you would for a regular template, but they will appear as settings.
For a single item template [name] should be equal to the name of your template file; "name.hbs" or "name.cshtml".
For a Multi-item template, [name] will be read from the manifest.json file.

In the following multi item manifest example [name] would be "list" and not the name of the template file ("overview").
So you would name the template settings files: "list-schema.json" and "list-options.json".
In case of a multi item template the template settings are valid for the combined list + detail template.

{
	"templates": {
		"list": {
			"type": "multiple",
			"title": "Overview",            
			"main": {
				"template": "overview.hbs",
			},
			"detail": {
				"template": "detail.hbs",
			}
		}
	}
}

Using template settings in your Template

You can use settings in your Handlebars templates using @root.Settings.MySetting.
Below is an example of a Template with a list of link, with a Template wide setting to open the links in a new window

{{#each Items}}
<a href="{{Link}}"{{#if @root.Settings.NewWindow}} target="_blank"{{/if}}>{{Text}}</a>
{{/each}}
{
  "type": "object",
  "properties": {
    	"NewWindow": {
			"title": "Open Links in new Window",
			"type":"boolean"
		}
  }
}