Node specific settings

Custom settings can be configured per node and loaded via the REST API.

1 Setting and retrieving custom settings

Node specific settings can be configured via the variable $NODE_SETTINGS using either the local ID or global ID or name of the node:


<?php

$NODE_SETTINGS['3D6C.bbcc391e-ae22-11e9-9f0d-00155df0382f'] = array(
	'resizing' => array(
		'aspect_ratios' => array(
			'4:3',
			'16:10'
		),
		'max_height' => 500
);

Configuration per local ID, global ID and name cannot be mixed. The CMS will first look for a configuration by global ID, if that is not found, by node name and if that is not found by local ID.

The settings can be retrieved via the REST API with requests to the /rest/node/[NODEID]/settings endpoint. In the resulting JSON response the configuration will be in the field data. With the configuration above, a request to /rest/node/1/settings would yield:


{
	"messages": [],
	"responseInfo": {
		"responseCode": "OK",
		"responseMessage": "Loaded settings for Node {1}"
	},
	"data": {
		"resizing": {
			"aspect_ratios": [
				"4:3",
				"16:10"
			],
			"max_height": 500
		}
	}
}

2 Global values

Global settings for all nodes can be configured in the variable $NODE_SETTINGS_GLOBAL. All entries in this array will be added to the node specific settings unless they already contain that setting.

NOTE: that the value types for settings must match in the global and node specific settings. For example a global array value cannot be overriden with a numeric value.

Loading settings for nodes without specific settings will just return the global settings.

For example the configuration


<?php

$NODE_SETTINGS_GLOBAL = array(
	'resizing' => array(
		'max_height' => 500
	),
	'allow_this' => false
);
	
$NODE_SETTINGS[1] = array(
	'resizing' => array(
		'aspect_ratios' => array(
			'4:3',
			'16:10'
		)
	)
);

would result in the following response from /rest/node/1/settings (note that the configuration for node 1 only contains the aspect ratios, the rest comes from the global settings):


{
	"messages": [],
	"responseInfo": {
		"responseCode": "OK",
		"responseMessage": "Loaded settings for Node {1}"
	},
	"data": {
		"allow_this": false,
		"resizing": {
			"aspect_ratios": [
				"4:3",
				"16:10"
			],
			"max_height": 500
		}
	}
}