Stefan Padberg
Stefan Padberg

Reputation: 527

TYPO3 how to modify TCA?

TYPO3 9, but is probably independent of TYPO3 version

I have installed news and eventnews. eventnews adds a field location_simple to the table tx_news_domain_model_news. In the backend this is of type input. I want it to be of type text. Therefore I added a file Configuration/TCA/Overrides/tx_news_domain_model_news.php to my sitepackage:

<?php
if( !defined('TYPO3_MODE') ) {
    die ('Access denied.');
}

// Modify location simple
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['location_simple']['config']['type'] = 'text';

But this has no effect.

My sitepackage is included at last position, so it should be able to overwrite the TCA of eventnews. What is correct the magic for this?

Upvotes: 2

Views: 1949

Answers (2)

Franz Holzinger
Franz Holzinger

Reputation: 998

You must add the extension 'news' to the dependencies of your extension. Then this will have the effect that the TCA of extension 'news' is included before your extension's TCA code is executed.

file ext_emconf.php:

$EM_CONF[$_EXTKEY] = [
...
    'constraints' =>
        [
            'depends' =>
                [
                    'typo3' => '11.5.0-12.4.99',
                    'php' => '7.4.0-8.2.99',
                    'news' => '9.3.0-11.2.99',
                ],
        ],
);

file composer.json:

"require": {
    "typo3/cms-core": "^11.5 || ^12.4",
    "php": "^7.4 || ^8",
    "news": "^9.3 || ^10 || ^11"
},

From the docs:

"If your extension modifies another extension, you actively need to make sure your extension is loaded after the extension you are modifying. This can be achieved by registering that other extension as a dependency (or suggestion) of yours."

see https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ExtensionArchitecture/HowTo/ExtendingTca/StoringChanges/Index.html#storing-changes-extension .

Upvotes: 0

Stefan Padberg
Stefan Padberg

Reputation: 527

This worked for me: rename my site package extension so that it has an extension key alphabetically after 'e'.

It seems as if the files in /Configuration/TCA/Overrides are read alphabetically. In my case I wanted to override eventnews. So my site package extension key had to begin with a letter in [f-z].

Upvotes: 1

Related Questions