Skip to content
Advertisement

TYPO3 fill backend fields in content element with database values

I’m trying to distribute JSON data from inside a tt_content database field into the other existing fields, like the TYPO3 default input field header.

I tried finding a hook which lets me handle the distribution manually like I could while saving via

$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][]

in my ext_localconf.php. I couldn’t find one. So I took a look at the TCA to see if there are possible settings I can use, but I couldn’t as well.

Do you know a way on how to do this data distribution manually?

Advertisement

Answer

I found the solution:

You have to do 2 things in your ext_localconf.php file

To change data before saving to the database you have to call:

$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = YourNamespaceHooksYourClass::class;

To handle data before it’s being loaded to the backend fields:

$GLOBALS ['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][YourNamespaceFormDataProviderYourOtherClass::class]['depends'][0] = TYPO3CMSBackendFormFormDataProviderDatabaseEditRow::class;

For loading into the frontend or template you need in your setup typoscript:

tt_content {
    your_content_element_name =< lib.contentElement
    your_content_element_name {
        templateRootPaths {
            1 = EXT:your_extension_name/Resources/Private/Templates/
        }
        partialRootPaths {
            1 = EXT:your_extension_name/Resources/Private/Partials/
        }
        templateName = YourTemplateName
        dataProcessing {
            1 = YourNamespaceDataProcessingYourClassProcessor
        }
    }
}

All those classes can be compared to the corresponding core classes.

I hope this helps someone in the future.

Kind regards!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement