仅为一种内容类型 (CType) 覆盖 imageManipulation/crop 的 TCA 配置
Override TCA config for imageManipulation/crop for only one content type (CType)
我有 三种 类型的内容元素(tt_content|类型),它们都使用一个 image
列,每个列都有一个 FAL 关系图片。
我想将 type = 'imageManipulation'
(Docs) 与 2 种不同的 配置用于 2 个内容元素,其中一个仅使用图像是。
由于 type = 'imageManipulation'
通常为 sys_file_reference
定义,因此对于所有用法。
是否可以使用 TCA 覆盖为不同的内容元素归档不同的配置?
我尝试了 columnsOverrides and overrideChildTca 的组合,但这暂时不起作用:
<?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/
但这也会出现在每个内容元素中。
我发现了错误。 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
],
],
],
]
],
],
]
],
]
]
];
}
})();
我有 三种 类型的内容元素(tt_content|类型),它们都使用一个 image
列,每个列都有一个 FAL 关系图片。
我想将 type = 'imageManipulation'
(Docs) 与 2 种不同的 配置用于 2 个内容元素,其中一个仅使用图像是。
由于 type = 'imageManipulation'
通常为 sys_file_reference
定义,因此对于所有用法。
是否可以使用 TCA 覆盖为不同的内容元素归档不同的配置?
我尝试了 columnsOverrides and overrideChildTca 的组合,但这暂时不起作用:
<?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/
但这也会出现在每个内容元素中。
我发现了错误。 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
],
],
],
]
],
],
]
],
]
]
];
}
})();