ext_tables.php
ext_tables.php
-
- Scope
- extension
- Path (Composer)
- packages/my_extension/ext_tables.php
- Path (Classic)
- typo3conf/ext/my_extension/ext_tables.php
ext_
is not always included in the global scope of the frontend context.tables. php This file is only included when
- a TYPO3 Backend or CLI request is happening
- or the TYPO3 Frontend is called and a valid backend user is authenticated
This file usually gets included later within the request and after TCA information is loaded, and a backend user is authenticated.
Hint
In many cases, the file
ext_
is no longer needed, sincetables. php TCA
definitions must be placed in files located at Configuration/TCA/.
Should not be used for
- TCA configurations for new tables. They should go in Configuration/TCA/sometable.php.
- TCA overrides of existing tables. They should go in Configuration/TCA/Overrides/somefile.php.
- calling
Extension
as this might break the frontend. They should go in Configuration/TCA/Overrides/somefile.php.Management Utility:: add To Insert Records () - calling
Extension
as this might break the frontend. They should go inManagement Utility:: add Static File () Configuration/TCA/Overrides/sys_template.php
Changed in version 12.0
Adding table options via
Extension
ExampleManagement Utility:: allow Table On Standard Pages ()
Should be used for
These are the typical functions that should be placed inside ext_tables.php
- Registering a scheduler tasks: Registering a scheduler task
- Registration of custom page types
- Extending the Backend user settings
Examples
Put the following in a file called ext_tables.php
in the main directory
of your extension. The file does not need to be registered but will be loaded
automatically:
<?php
declare(strict_types=1);
use MyVendor\MyExtension\Backend\MyClass;
defined('TYPO3') or die();
// Add your code here
MyClass::doSomething();
Read why the check for the TYPO3 constant is necessary.
Registering a scheduler task
Scheduler tasks get registered in ext_tables.php
as well. Note that the system extension "scheduler" has
to be installed for this to work.
<?php
declare(strict_types=1);
use TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionAdditionalFieldProvider;
use TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask;
defined('TYPO3') or die();
$lll = 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xlf:';
// Add caching framework garbage collection task
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']
[CachingFrameworkGarbageCollectionTask::class] = [
'extension' => 'my_extension',
'title' => $lll . 'cachingFrameworkGarbageCollection.name',
'description' => $lll . 'cachingFrameworkGarbageCollection.description',
'additionalFields' =>
CachingFrameworkGarbageCollectionAdditionalFieldProvider::class,
];
Registering a backend module
Changed in version 12.0
The usage of
Extension
is
deprecated. In TYPO3 v12 it is not evaluated anymore. Register modules in
Extension folder Configuration/Backend.
If your extension needs to provide compatibility with TYPO3 v11 as well as v12
you can check which version is loaded in the ext_tables.php
and call
Extension
for v11 to register an Extbase backend
module:
// use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
ExtensionUtility::registerModule(
'ExtensionName', // Extension Name in CamelCase
'web', // the main module
'mysubmodulekey', // Submodule key
'bottom', // Position
[
'MyController' => 'list,show,new',
],
[
'access' => 'user,group',
'icon' => 'EXT:my_extension/ext_icon.svg',
'labels' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang_statistics.xlf',
]
);
Allowing a tables records to be added to Standard pages
Changed in version 12.0
The usage of
Extension
is
deprecated. The method will be removed in TYPO3 v13.0. Use TCA ctrl option
ignorePageTypeRestriction
instead.
If your extension needs to provide compatibility with TYPO3 v11 as well as v12
you can check which version is loaded in the ext_tables.php
and call
allow
for v11:
<?php
declare(strict_types=1);
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
defined('TYPO3') or die();
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
if ($versionInformation->getMajorVersion() < 12) {
ExtensionManagementUtility::allowTableOnStandardPages(
'tx_myextension_domain_model_mymodel',
);
}
Note
Use ignorePageTypeRestriction to achieve the same functionality for TYPO3 v12.