Layouts
Last updated
Last updated
As a plugin developer, you customize the new/edit plugin instance screens with a layout JSON file. You can group properties into categories and choose the type of field representing each of them.
A plugin layout is bound to a plugin version.
It is optional, except for audience segment feeds. A default layout is used to show all properties of a plugin version (Note that there is no layout file associated to this default layout).
A plugin layout is composed of:
A layout JSON file
A non-empty list of translation CSV files
This file declares the different elements of the configuration UI.
Here is the JSON schema. You can validate your files with it in your favorite JSON validation tool.
Attribute
Type
Description
version
a string
the version of the layout
Attribute
Type
Description
title
a string
the section title
sub_title
a string
the section subtitle
advanced_fields
a list of Fields
it defines the advanced fields of the section, which can be graphically expanded or not (see below for the Definition)
Attribute
Type
Description
property_technical_name
a string
the technical name of the property represented by the field
label
a string
the label preceding the field type, on its left in the form
tooltip
a string (optional)
the help text displayed in the tooltip following the field type, on its right in the form
enum
a list of Enum resources (optional)
an enum describing the possible values of the field (used by some field types : SELECT, MULTI_SELECT, SWITCH, RADIO, CHECKBOX) (see below for the Definition)
max_length
an integer (optional)
a maximum length of the text in the field type; used only in the case TEXTAREA
required
a boolean (optional)
it defines whether the field is mandatory or not; if the value is not specified, then it isn't (the default value is false)
The possible field types are the following:
TEXTAREA
URL
DATA_FILE
HTML
NUMBER
SELECT
MULTI_SELECT
IMAGE
INPUT
INPUT_NUMBER
SWITCH
RADIO
CHECKBOX
DATE
DATE_RANGE
Attribute
Type
Description
value
a string
the value of the enum, which will be affected to the property
label
a string
the label of the enum, which will be displayed in the field
Attribute
Type
Description
large_icon_asset_id
an integer
the asset id of the large icon representing the plugin layout
small_icon_asset_id
an integer
the asset id of the small icon representing the plugin layout
display_name
a string
the plugin version's name (visible in the plugin listing and the form page)
description
a string
a description of the plugin version (visible in the plugin listing and the form page)
Note that the assets must belong to the same organisation than the plugin.
Translation csv files are used to support localization. Given a layout json file, for each locale, a translation csv file can be provided. The plugin developer can refer to a value in the layout json file by surrounding the value name with double curly brackets (hence, referring to value val is done with {{val}}
in the json file). Those values can be found anywhere in the layout json file. For example, an excerpt of a layout json file, referring to the value val when defining a label in a field, looks like:
A translation csv is composed of two comma-separated columns. The header of the table is KEY,VALUE. The first column corresponds to the keys, i.e the names of the values (val in the preceding example). The second column corresponds to the values by which the keys will be replaced when the layout will be displayed in Navigator.Considering the previous excerpt of a layout json file, a (brief) corresponding US English (en-US locale) translation csv file could be:
Here is a sample translation file associated with the sample layout.json file in this page
GET
https://api.mediarithmics.com/v1/plugins/:pluginId/versions/:versionId/properties_layout
Retrieves the already uploaded layout JSON file for a plugin version. You can retrieve the layout.json file with translation tokens or with translation values.
plugin_id
integer
The ID of the plugin
version_id
integer
The ID of the version
locale
string
Replaces all translation tokens with values in the specified locale Example: locale=en-US
PUT
https://api.mediarithmics.com/v1/plugins/:pluginId/versions/:versionId/properties_layout
Updates the layout JSON file for a plugin version
plugin_id
integer
The ID of the plugin
version_id
integer
The ID of the version
body
string
The layout.json file content
In case of JSON not structured as expected
error, you can use Schema to validate your file.
GET
https://api.mediarithmics.com/v1/plugins/:pluginId/versions/:versionId/properties_layout/localizations/locale=:locale
Retrieves the translation file of a plugin version in the specified locale
locale
string
The locale in which to retrieve the CSV file.
plugin_id
integer
The ID of the plugin.
version_id
string
The ID of the version.
PUT
https://api.mediarithmics.com/v1/plugins/:pluginId/versions/:versionId/properties_layout/localizations/locale=en-US
Retrieves the translation file of a plugin version in the specified locale
locale
string
The locale in which to retrieve the CSV file.
plugin_id
integer
The ID of the plugin
version_id
integer
The ID of the version
body
string
The content of the file