typo3

How can i duplicate referenced Record Objects when copying content elements/pages?


My tt_content TCA has a field with type "inline" with a reference to an record object in my extension. When i'm copying the content element with the inline field, the inline references are not being copied. All referenced records in my extension tables are ignored. I guess that's the expected behavior? Is there ANY way to duplicate those items in the referenced tables when copying pages / content elements?


$GLOBALS['TCA']['tt_content']['types']['main_banner']['columnsOverrides'] = [
 'tx_headline_lines' => [
    'config' => [
     'type' => 'inline',
      'foreign_table' => 'tx_headline_highlight_line',
      'foreign_field' => 'tx_headline',
      'foreign_label' => 'text',
    ]
  ]

I cant find a way to duplicate the referenced "record objects" when copying the parent content element or the page containing the element. Can anybody give me a hint how to accomplish that? There should be a quite easy solution because i cant imaging that's not such a specific or strange feature..

Thanks for any help.


Solution

  • When working with TYPO3 and inline fields in the TCA configuration, TYPO3 already handles the duplication of related child records when you copy a parent record, as long as the configuration is properly set up.

    This behavior is managed in the DataHandler class, specifically in the copyRecord() method, which ensures that referenced child records are duplicated. You can refer to the source code for more details : https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L4117

    In your case, you should verify that the 'tx_headline' field is correctly storing the UID of the parent record in the database.