.. include:: ../../Includes.txt .. _administration-children: Child records configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^ The "children" property is used to create nested structures, generally MM tables where additional information needs to be stored. This will correspond to :ref:`inline-type ("IRRE") fields ` with MM tables having a primary key field ("uid"). See the :ref:`Mapping data ` chapter for an overview of import scenarios which may help understand this feature. **Example:** .. code-block:: php $GLOBALS['TCA']['tx_externalimporttest_product']['columns']['pictures']['external'] = [ 'base' => [ 'field' => 'Pictures', // remote db field 'transformations' => [ 10 => [ 'userFunction' => [ 'class' => \Cobweb\ExternalImport\Transformation\ImageTransformation::class, 'method' => 'saveImageFromUri', 'parameters' => [ 'storage' => '1:importedpictures', // local folder for files ] ] ] ], 'children' => [ 'table' => 'sys_file_reference', 'columns' => [ 'uid_local' => [ 'field' => 'pictures' ], 'uid_foreign' => [ 'field' => '__parent.id__' ], 'title' => [ 'field' => 'picture_title' ], 'tablenames' => [ 'value' => 'tx_externalimporttest_product' ], 'fieldname' => [ 'value' => 'pictures' ], 'table_local' => [ 'value' => 'sys_file' ] ], 'controlColumnsForUpdate' => 'uid_local, uid_foreign, tablenames, fieldname, table_local', 'controlColumnsForDelete' => 'uid_foreign, tablenames, fieldname, table_local', ] ... ] ] .. _administration-children-properties: Properties """""""""" .. container:: ts-properties ========================= ==================== =================== Property Data type Step/Scope ========================= ==================== =================== table_ string Store data columns_ array Store data controlColumnsForUpdate_ string Store data controlColumnsForDelete_ string Store data disabledOperations_ string Store data ========================= ==================== =================== .. _administration-children-properties-table: table ~~~~~ Type string Description Name of the nested table. This information is mandatory. Scope Store data .. _administration-children-properties-columns: columns ~~~~~~~ Type array Description List of columns (database fields) needed for the nested table. This is an associative array, using the column name as the key. Then each column must have one of two properties: value This is a simple value that will be used for each entry into the nested table. Use it for invariants like the "tablenames" field of a MM table. field This is the name of a field that is available in the imported data. The value is copied from the current record. Note that such fields can be any of the mapped columns, any of the :ref:`additionalFields ` or any of the :ref:`substructureFields `. The special value :code:`__parent.id__` refers to the primary key of the current record and will typically be used for "uid_local" or "uid_foreign" fields in MM tables, depending on how the relation is built. Scope Store data .. _administration-children-properties-control-columns-for-update: controlColumnsForUpdate ~~~~~~~~~~~~~~~~~~~~~~~ Type string Description Comma-separated list of columns that need to be used for checking if a child record already exists. All these columns must exist in the list of :ref:`columns ` defined above. Defining this property ensures that existing relations are updated instead of being created anew. This list should contain all columns that are significant for identifying a child record without ambiguity. In the example above, we have: .. code-block:: php 'controlColumnsForUpdate' => 'uid_local, uid_foreign, tablenames, fieldname, table_local', These are all the columns that need to be queried in the "sys_file_reference" table to be sure that we are targeting the right record in the database. Any missing information might mean retrieving another record (for a different table or field, or whatever). .. note:: If this property is not defined, all children records will be considered to be new. If :ref:`controlColumnsForDelete ` is defined and the "delete" operation is not :ref:`disabled `, all existing child relations will be deleted upon each import. Scope Store data .. _administration-children-properties-control-columns-for-delete: controlColumnsForDelete ~~~~~~~~~~~~~~~~~~~~~~~ Type string Description This is similar to :ref:`controlColumnsForUpdate ` but for finding out which existing relations are no longer relevant and need to be deleted. It is not the same list of fields as you need to leave out the field which references the relation on the "other side". In the case of "sys_file_reference", you would leave out "uid_local", which is the reference to the "sys_file" table. .. note:: If this property is not defined, existing children records will not be checked and thus never be deleted. Scope Store data .. _administration-children-properties-control-columns-for-disabled-operations: disabledOperations ~~~~~~~~~~~~~~~~~~ Type string Description Comma-separated list of operations which should not take place. This can be "insert" (no new child records), "update" (no update to existing child records) and/or "delete" (no removal of existing child records). .. note:: This applies only when a parent record is being updated. When a parent record is being created, it does not make sense to forbid creation of its child records. Scope Store data