Online-Adventskalender in jede Website einbinden.

Jetzt starten!

Zusätzliche TCA-Felder und -Tools

Diese Erweiterung hilft Ihnen dabei, Ihren TCA übersichtlich und leicht wartbar zu halten.

Features:

  • Bietet Methoden für Tab-Label
  • Bietet Methoden für oft verwendete Felder wie sys_language_uid, hidden und mehr
  • Bietet Konfigurationsvoreinstellungen für den Markdown-t3editor, Prozentzahlen-Felder, Währungs-Felde und weitere

Verwendung der vollständigen Konfigurationen

return [
   'columns' => [
        'information' => \CodingMs\AdditionalTca\Tca\Configuration::full('information', $table, $extKey),
        'sys_language_uid' => \CodingMs\AdditionalTca\Tca\Configuration::full('sys_language_uid'),
        'l10n_parent' => \CodingMs\AdditionalTca\Tca\Configuration::full('l10n_parent'),
        'l10n_diffsource' => \CodingMs\AdditionalTca\Tca\Configuration::full('l10n_diffsource'),
        't3ver_label' => \CodingMs\AdditionalTca\Tca\Configuration::full('t3ver_label'),
        'hidden' => \CodingMs\AdditionalTca\Tca\Configuration::full('hidden'),
        'starttime' => \CodingMs\AdditionalTca\Tca\Configuration::full('starttime'),
        'endtime' => \CodingMs\AdditionalTca\Tca\Configuration::full('endtime'),
    ],
];

Verwendung von Labeln

return [
   'types' => [
        '1' => ['showitem' => '
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_general') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_language') . ',
            sys_language_uid,
            l10n_parent,
            l10n_diffsource,
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_access') . ',
            hidden,
            starttime,
            endtime,
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_notes') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_extended') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_seo') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_relations') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_images') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_files') . ',
        --div--;' . \CodingMs\AdditionalTca\Tca\Configuration::label('tab_markdown') . ',
        '],
    ],
];

Verwendung der Feldkonfiguration

$extKey = 'shop';
$table = 'tx_shop_domain_model_product';
$lll = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table;
return [
   'columns' => [
        'slug' => [
            // field: ... -> Database field for auto generate the slug
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('slug', false, false, '', ['field' => 'answer']),
        ],
        'rte' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('rte'),
            'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled]',
        ],
        'textareaSmall' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('textareaSmall'),
        ],
        'textareaLarge' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('textareaLarge'),
        ],
        'markdown' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('markdown'),
            'defaultExtras' => 'fixed-font:enable-tab',
        ],
        'html' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('html'),
            'defaultExtras' => 'fixed-font:enable-tab',
        ],
        'int' => [
            // lower:, upper: enter range for integer, set both or none (not just one)
            // without these -> user can enter any integer
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('int', false, false, '', ['lower' => 1, 'upper' => 50]),
        ],
        'coordinate' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('coordinate'),
        ],
        'currency' => [
            // dbType: float -> Database field is a float number
            // without dbType -> Database field is an integer number
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('currency', false, false, '', ['dbType' => 'float']),
        ],
        'percent' => [
            // dbType: float -> Database field is a float number
            // without dbType -> Database field is an integer number
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('percent', false, false, '', ['dbType' => 'float']),
        ],
        'string' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('string'),
        ],
        'email' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('email'),
        ],
        'checkbox' => [
            // Checkbox label can be assigned as LLL as well
            // For example:
            // get('checkbox', false, false, $lll . '.in_stock_label')
            // get('checkbox', false, false, 'LLL:EXT:locallang.xlf:in_stock_label')
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('checkbox', false, false, 'Checkbox label'),
        ],
        'link' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get(
                'link',
                false,
                false,
                $lll . '.canonical_link',
                [
                    'title' => $lll . '.canonical_link',
                    'blindLinkFields' => 'class,target,title',
                    // Possible values: file, folder, mail, page, spec, telephone and url
                    'blindLinkOptions' => 'mail,folder,file,telephone,shop_product,url,news_news'
                ]
            ),
        ],
        'date' => [
            // dbType: timestamp -> Database field is an integer for timestamps
            // without dbType -> Database field is a date string
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('date', false, false, '', ['dbType' => 'timestamp']),
        ],
        'dateTime' => [
            // dbType: timestamp -> Database field is an integer for timestamps
            // without dbType -> Database field is a date string
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('dateTime', false, false, '', ['dbType' => 'timestamp']),
        ],
        'select' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('select', true, false, '', [
                [$lll . '.template_default', 'Default'],
                [$lll . '.template_with_single_view', 'WithSingleView'],
            ]),
        ],
        'fileSingle' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('fileSingle'),
        ],
        'fileCollectionSingleInline' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('fileCollectionSingleInline'),
        ],
        'imageSingleAltTitle' => [
            // field: ... -> Database field for foreign_match_fields.fieldname
            // table: ... -> Database field for foreign_match_fields.tablenames
            // fileTypes: Defines the allowed file types (default: png,jpg,jpeg)
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('imageSingleAltTitle', false, false, '', ['field' => 'image', 'table' => 'tx_openimmo_domain_model_anhang', 'fileTypes' => 'png,jpg,jpeg,svg']),
        ],
        'imageSingleTitleDescription' => [
            // field: ... -> Database field for foreign_match_fields.fieldname
            // table: ... -> Database field for foreign_match_fields.tablenames
            // fileTypes: Defines the allowed file types (default: png,jpg,jpeg)
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('imageSingleTitleDescription', false, false, '', ['field' => 'image', 'table' => 'tx_openimmo_domain_model_anhang', 'fileTypes' => 'png,jpg,jpeg,svg']),
        ],
        'images' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('images'),
        ],
        'frontendUserSingle' => [
            'config' => \CodingMs\AdditionalTca\Tca\Configuration::get('frontendUserSingle'),
        ],
    ],
];

Verwendung der benutzerdefinierten Feldkonfiguration

EXT:questions/Classes/Tca/Configuration.php

<?php declare(strict_types=1);
namespace CodingMs\Questions\Tca;
use CodingMs\AdditionalTca\Tca\Configuration as ConfigurationDefaults;

class Configuration extends ConfigurationDefaults
{

    /**
     * @param string $type
     * @param bool $required
     * @param bool $readonly
     * @param string $label
     * @param array $options
     * @return array
     */
    public static function get($type, $required = false, $readonly = false, $label = '', array $options=[]): array
    {
        switch ($type) {
            case 'questionCategories':
                $config = [
                    'type' => 'select',
                    'renderType' => 'selectMultipleSideBySide',
                    'foreign_table' => 'tx_questions_domain_model_questioncategory',
                    'MM' => 'tx_questions_question_questioncategory_mm',
                    'foreign_table_where' => 'ORDER BY title',
                    'size' => 10,
                    'autoSizeMax' => 30,
                    'minitems' => 1,
                    'maxitems' => 9999,
                    'multiple' => 0,
                ];
                break;
            case 'anotherCustom':
                // ...
                break;
            default:
                $config = parent::get($type, $required, $readonly, $label, $options);
                break;
        }
        if ($readonly) {
            $config['readOnly'] = true;
        }
        return $config;
    }
}

Verwendung im eigenen TCA:

return [
   'columns' => [
        'category' => [
            'exclude' => 0,
            'label' => $lll . '.category',
            'config' => \CodingMs\Questions\Tca\Configuration::get('questionCategories'),
        ],
    ],
];

Verwendung des Informationsfeldes

FlexForm

<information>
    <TCEforms>
        <exclude>0</exclude>
        <label>Support</label>
        <config>
            <type>user</type>
            <renderType>Information</renderType>
            <parameters>
                <extensionKey>questions</extensionKey>
            </parameters>
        </config>
    </TCEforms>
</information>

ext_conf_template.txt

# cat=extension/updateService/10; type=boolean; label= LLL:EXT:additional_tca/Resources/Private/Language/locallang.xlf:tx_additionaltca_ext_conf_template.extension_update_service_active
extension.updateService.active = 1

# cat=extension/updateService/20; type=string; label= LLL:EXT:additional_tca/Resources/Private/Language/locallang.xlf:tx_additionaltca_ext_conf_template.extension_update_service_email
extension.updateService.email = typo3(at)coding(dot)ms

Beispiel für eine einfache TCA-Datei

<?php
$extKey = 'questions';
$table = 'tx_questions_domain_model_questioncategory';
$lll = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table;

return [
    'ctrl' => [
        'title' => $lll,
        'label' => 'title',
        'label_alt' => 'description',
        'label_alt_force' => true,
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'sortby' => 'sorting',
        'versioningWS' => true,
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'delete' => 'deleted',
        'enablecolumns' => [
            'disabled' => 'hidden',
        ],
        'searchFields' => 'title,description',
        'iconfile' => 'EXT:questions/Resources/Public/Icons/iconmonstr-help-3.svg'
    ],
    'interface' => [
        'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, description',
    ],
    'types' => [
        '1' => ['showitem' => '
        --div--;' . \CodingMs\Questions\Tca\Configuration::label('tab_general') . ',
            information,
            title,
            description,
        --div--;' . \CodingMs\Questions\Tca\Configuration::label('tab_language') . ',
            sys_language_uid,
            l10n_parent,
            l10n_diffsource,
        --div--;' . \CodingMs\Questions\Tca\Configuration::label('tab_access') . ',
            hidden,
            starttime,
            endtime
        '],
    ],
    'columns' => [
        'information' =>  \CodingMs\Questions\Tca\Configuration::full('information', '', $extKey),
        'sys_language_uid'  => \CodingMs\Questions\Tca\Configuration::full('sys_language_uid'),
        'l10n_parent' => \CodingMs\Questions\Tca\Configuration::full('l10n_parent'),
        'l10n_diffsource' => \CodingMs\Questions\Tca\Configuration::full('l10n_diffsource'),
        't3ver_label' => \CodingMs\Questions\Tca\Configuration::full('t3ver_label'),
        'hidden' => \CodingMs\Questions\Tca\Configuration::full('hidden'),
        'title' => [
            'exclude' => 0,
            'label' => $lll . '.title',
            'config'  => \CodingMs\Questions\Tca\Configuration::get('string', true),
        ],
        'description' => [
            'exclude' => 0,
            'label' => $lll . '.description',
            'config'  => \CodingMs\Questions\Tca\Configuration::get('string'),
        ],
    ],
];