仅为一种内容类型(CType)覆盖imageManipulation / crop的TCA配置

问题描述 投票:0回答:1

我有三种类型的内容元素(tt_content | types),它们都使用image列,每个FAL关系用于一个图像。

我想使用2个内容元素type = 'imageManipulation'Docs)有两种不同的配置,而且只有一个图像。

由于type = 'imageManipulation'通常是针对sys_file_reference定义的,所以对于所有用法都是如此。

是否可以使用TCA覆盖来存档不同内容元素的不同配置?

我尝试了columnsOverridesoverrideChildTca的组合,但这在当下不起作用:

<?php
defined('TYPO3_MODE') or die();

(function () {
    if (is_array($GLOBALS['TCA']['tt_content']['types']['mask_teaser_hero'])) {
        $GLOBALS['TCA']['tt_content']['types']['mask_teaser_hero']['columnsOverrides'] = [
            'tx_maskproject_teaserimage' => [
                'config' => [
                    'overrideChildTca' => [
                        'columns' => [
                            'crop' => [
                                'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.crop',
                                'config' => [
                                    'type' => 'imageManipulation',
                                    'cropVariants' => [
                                        'mobile' => [
                                            'title' => 'Mobile',
                                            'selectedRatio' => '4:3',
                                            'allowedAspectRatios' => [
                                                '4:3' => [
                                                    'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.4_3',
                                                    'value' => 4 / 3
                                                ],
                                            ],
                                        ],
                                        'desktop' => [
                                            'title' => 'Desktop',
                                            'selectedRatio' => '16:9',
                                            'allowedAspectRatios' => [
                                                '16:9' => [
                                                    'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.16_9',
                                                    'value' => 16 / 9
                                                ],
                                            ],
                                        ],
                                    ]
                                ],
                            ],
                        ]
                    ],
                ]
            ]
        ];
    }

})();

我首先想到了Typoscript TCEFORM:https://metinyilmaz.de/artikel/typo3-image-cropvariants/

但这也会出现在每个内容元素中。

typo3 typo3-9.x
1个回答
1
投票

我发现了错误。 TCA覆盖是正确的。但类型不是。

我使用EXT:mask_export作为内容元素。在问题的示例中,我覆盖了EXT:mask添加的内容元素。但导出的内容元素是不同的内容元素。

正确的是:

<?php
defined('TYPO3_MODE') or die();

(function () {
    if (is_array($GLOBALS['TCA']['tt_content']['types']['myextname_teaser_hero'])) {
        $GLOBALS['TCA']['tt_content']['types']['myextname_teaser_hero']['columnsOverrides'] = [
            'tx_myextname_teaserimage' => [
                'config' => [
                    'overrideChildTca' => [
                        'columns' => [
                            'crop' => [
                                'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.crop',
                                'config' => [
                                    'type' => 'imageManipulation',
                                    'cropVariants' => [
                                        'mobile' => [
                                            'title' => 'Mobile',
                                            'selectedRatio' => '4:3',
                                            'allowedAspectRatios' => [
                                                '4:3' => [
                                                    'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.4_3',
                                                    'value' => 4 / 3
                                                ],
                                            ],
                                        ],
                                        'desktop' => [
                                            'title' => 'Desktop',
                                            'selectedRatio' => '16:9',
                                            'allowedAspectRatios' => [
                                                '16:9' => [
                                                    'title' => 'LLL:EXT:lang/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.16_9',
                                                    'value' => 16 / 9
                                                ],
                                            ],
                                        ],
                                    ]
                                ],
                            ],
                        ]
                    ],
                ]
            ]
        ];
    }

})();
© www.soinside.com 2019 - 2024. All rights reserved.