Extension repository & Download
extensions.typo3.org/extension/cc_jsonflex github.com/coelnconcept/cc_jsonflex
Composer
composer req coelnconcept/cc-jsonflex
Introduction
TYPO3 uses FlexForms to store dynamic structured content in one database column, using XML as format.
Our approach is to use the widely available format JSON and the well-established TCA configuration.
What does it do?
This extension provides the renderType jsonFlex for the TCA configuration to extend a database field into multiple dynamic sub-fields.
Einleitung
TYPO3 verwendet FlexForms, um dynamisch strukturierte Inhalte in einer Datenbankspalte im XML-Format zu speichern.
Unser Ansatz besteht darin, das weit verbreitete Format JSON und die bewährte TCA-Konfiguration zu verwenden.
Was macht die Extension?
Diese Erweiterung stellt den renderType jsonFlex für die TCA-Konfiguration bereit, um ein Datenbankfeld in mehrere dynamische Unterfelder zu erweitern.
Usage
Configuation:
- 'type' => 'user'
Do not use json as type, it would result in special issues. user is the correct type. - 'renderType' => 'jsonFlex'
- 'columns' => [ ... ]
configure the sub-columns - Optional: 'mergeDataOnUpdate' => true
If this option is set, already existing JSON data will be merged. This is especially useful, if you have a mix of auto-created data and parts you want to edit.
Verwendung
Konfiguration
- 'type' => 'user'
Verwenden Sie nicht json als Typ, da dies zu besonderen Problemen führen würde. user ist der richtige Typ. - 'renderType' => 'jsonFlex'
- 'columns' => [ ... ]
Konfigurieren Sie die Unterkolumnen. - Optional: 'mergeDataOnUpdate' => true
Wenn diese Option aktiviert ist, werden bereits vorhandene JSON-Daten zusammengeführt. Dies ist besonders nützlich, wenn Sie eine Mischung aus automatisch erstellten Daten und Teilen haben, die Sie bearbeiten möchten.
Example 1
Simple fields
Beispiel 1
Einfache Felder
PHP
'jsondata' => [
'label' => 'Database column for example 1',
'config' => [
'type' => 'user',
'renderType' => 'jsonFlex',
'columns' => [
'placeholder' => [
'label' => 'JSON field: simple text input',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'required' => [
'label' => 'JSON field: simple checkbox',
'config' => [
'type' => 'check',
],
],
'mediatype' => [
'label' => 'JSON field: simple select',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', ''],
['Image', 'image'],
['Audio', 'audio'],
['Video', 'video'],
],
],
],
],
]
]
Example 2
Using Record Types and palettes.
Important: The type column has to be a real database column, it cannot be a JsonFlex field.
Beispiel 2
Verwendung von Datensatztypen und Paletten.
Wichtig: Die Spalte type muss eine echte Datenbankspalte sein, sie kann kein JsonFlex-Feld sein.
PHP
'type' => [
'label' => 'Dataset type, like CType in tt_content',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 'default'],
['Container element', 'container'],
['Special content', 'special'],
]
]
],
'datafields' => [
'label' => 'Database column for example 2',
'config' => [
'type' => 'user',
'renderType' => 'jsonFlex',
'types' => [
'default' => ['showitem' => '--palette--;;inputPalette, mediatype'],
'container' => ['showitem' => 'mediatype'],
'special' => ['showitem' => '--palette--;;inputPalette'],
],
'palettes' => [
'inputPalette' => [
'label' => 'Palette with placeholder and required-checkbox',
'showitem' => 'placeholder, required',
],
],
'columns' => [
'placeholder' => [
'label' => 'JSON field: simple text input',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'required' => [
'label' => 'JSON field: simple checkbox',
'config' => [
'type' => 'check',
],
],
'mediatype' => [
'label' => 'JSON field: simple select',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', ''],
['Image', 'image'],
['Audio', 'audio'],
['Video', 'video'],
],
],
],
],
]
]
Example 3
Nested JsonFlex columns.
Beispiel 3
Verschachtelte JsonFlex-Spalten.
PHP
'datafields' => [
'label' => 'Database column for example 2',
'config' => [
'type' => 'user',
'renderType' => 'jsonFlex',
'columns' => [
'placeholder' => [
'label' => 'JSON field: simple text input',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'other' => [
'label' => 'JSON field: nested jsonFlex',
'config' => [
'type' => 'user',
'renderType' => 'jsonFlex',
'columns' => [
...
]
],
],
],
]
]
What works
- Column-Types input, check, select, text, folder, group
- Record Types and palettes.
What does not works
- Column-Type category
What is not testet
- Everything else
Was funktioniert
- Spalten-Typen input, check, select, text, folder, group
- Datensatztypen und Paletten.
Was funktioniert nicht
- Spalten-Typ category
Was ist nicht getestet
- Alles sonstige
