enablecolumns

enablecolumns
Type
array
Path
$GLOBALS['TCA'][$table]['ctrl']
Scope
Proc. / Display

Specifies which publishing control features are automatically implemented for the table.

This includes that records can be "disabled" or "hidden", have a starting and/or ending time and be access controlled so only a certain front end user group can access them. This property is used by the RestrictionBuilder to create SQL fragments.

These are the keys in the array you can use. Each of the values must be a field name in the table which should be used for the feature:

disabled
Defines which field serves as hidden/disabled flag.
starttime
Defines which field contains the starting time.
endtime
Defines which field contains the ending time.
fe_group
Defines which field is used for access control via a selection of FE user groups.
Record information shown editing an example record

See also the delete feature which is related, but is active for both frontend and backend.

Examples

Make table hideable

EXT:my_extension/Configuration/TCA/tx_myextension_domain_model_something.php
<?php
return [
    'ctrl' => [
        'enablecolumns' => [
            'disabled' => 'hidden',
        ],
        // ...
    ],
    'columns' => [
        'hidden' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.enabled',
            'config' => [
                'type' => 'check',
                'renderType' => 'checkboxToggle',
                'items' => [
                    [
                        'label' => '',
                        'invertStateDisplay' => true
                    ]
                ],
            ]
        ],
        // ...
    ],
];
Copied!

Common enable fields

Record information shown editing an example record
EXT:styleguide/Configuration/TCA/tx_styleguide_ctrl_common.php
[
    'ctrl' => [
        'title' => 'Form engine - Common table control',
        'label' => 'title',
        'descriptionColumn' => 'description',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'delete' => 'deleted',
        'sortby' => 'sorting',
        'default_sortby' => 'title',
        'versioningWS' => true,
        'rootLevel' => -1,
        'iconfile' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
        'origUid' => 't3_origuid',
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'translationSource' => 'l10n_source',
        'searchFields' => 'title,description',
        'enablecolumns' => [
            'disabled' => 'hidden',
            'starttime' => 'starttime',
            'endtime' => 'endtime',
        ],
        'security' => [
            'ignorePageTypeRestriction' => true,
        ],
    ],
]
Copied!

Enablecolumns / enablefields usage

Most ways of retrieving records in the frontend automatically respect the ctrl->enablecolumns settings:

Enablecolumns in TypoScript

Records retrieved in TypoScript via the objects RECORDS, CONTENT automatically respect the settings in section ctrl->enablecolumns.

Enablecolumns / enablefields in Extbase

In Extbase repositories the records are hidden in the frontend by default, however this behaviour can be disabled by setting $querySettings->setIgnoreEnableFields(true) in the repository.

Enablecolumns in queries

Using the QueryBuilder enable columns restrictions are automatically applied.

The same is true when select() is called on the connection.

See the Restriction builder for details.

However this could be disabled by setting:

EXT:my_extension/SomeClass.php
// use TYPO3\CMS\Core\Utility\GeneralUtility;
// use TYPO3\CMS\Core\Database\ConnectionPool;
// use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder
   ->getRestrictions()
   // Use with care, the following may reveal information:
   ->removeAll()
   ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
Copied!