Custom Data Type
A custom data type can be used to extends easydb with your own data type. A custom data type can store any data in a JSON-Map. The Input, Output and Search-Mapping of that type can be managed by plugin code.
An example for a custom data type is Web link or the Remote Plugin both provided by Programmfabrik and made open source on Github.
custom_types:
link:
config:
schema:
- name: title
parameters:
type:
type: select
options: ["none", "text", "text-l10n"]
- name: add_timestamp
parameters:
value:
type: bool
mask:
- name: editor_style
parameters:
value:
type: select
options: ["inline", "popover"]
mapping:
url:
type: text_oneline
text_plain:
type: text
tld:
type: text
text:
type: text_l10n_oneline
Search-Mapping
The search mapping for the fields of the custom data type can be defined in the plugin configuration. Under the node mapping
, the field names and their type
can be defined:
Types that can be specified are:
text
- a text field
text_oneline
- a one line text field
text_l10n
- a multilanguage text field
text_l10n_oneline
- a multilanguage, one line text field
JSON Definition
The plugin generates a JSON object that is saved in the database. The frontend uses the information in the object to display the custom data type.
{
"url": "https://docs.easydb.de",
"tld": "de",
"hostname": "docs.easydb.de",
"text": {
"de-DE": "Welcome to the easydb documentation",
"en-US": "Willkommen zur easydb-Dokumentation"
},
"_fulltext": {
"string": "https://docs.easydb.de",
"l10ntext": {
"de-DE": "Welcome to the easydb documentation",
"en-US": "Willkommen zur easydb-Dokumentation"
}
},
"_standard": {
"l10ntext": {
"de-DE": "Welcome to the easydb documentation",
"en-US": "Willkommen zur easydb-Dokumentation"
}
}
}
This example shows the content of the JSON definition of the custom data type Weblink.
General Keys
_fulltext
This is used to add the content of the plugin to the elasticsearch index. The content of these fields is copied to _all_text
and _all_string
fields and can be found in the fulltext search.
text
- a searchable text that is used for all languages
- folding is applied (see Fields, “One-line text”)
string
- a general search string that is used for all languages
- there is no folding applied, so the search only works for exact search input (see Fields, “Simple text (string)”)
l10ntext
- object with localized strings for multiple frontend languages
_standard
Custom Data Types can define their own standard, that is parsed by the server and is displayed in the frontend. The standard definition is part of the json object that is generated by the plugin.
Two different standard versions can be saved:
-
text
- a simple string that is used for the standard for all languages
-
l10ntext
- object with localized strings with standards for multiple frontend languages
Custom Data Type specific Keys
The JSON object can contain multiple extra fields that contain data and information and is interpreted by the plugin. For example, the Weblink Custom Data Type Plugin contains the following fields:
"url"
: String that saves the URL of the Link. It can be set by the user in the frontend"text"
: Localized strings with a short description of the URL that can be set in the frontend"tld"
: String with the top level domain. Is generated by the plugin from theurl
"hostname"
: String with host name. Is generated by the plugin from theurl
Automatic updates of custom data types
The server can automatically update Custom Data Types (especially Custom Data Types that get their data from external sources), if the plugin provides an update script.
For more details, see Automatic updates of custom data types