【发布时间】:2021-08-07 17:26:17
【问题描述】:
我想使用 TYPO3 v9.5 核心制作一个自定义内容元素,该元素具有内联类型的自定义内容元素(子元素)。他们每个人都有来自 tt_content 的字段标题和图像。
所以我已经得到的是: custom content element with inline child
通过单击展开子元素,我得到如下内容: expanded child element with image and header field
到目前为止,一切都很好,但是当我查看我的页面内容时,为什么我的孩子不在父元素中: I want them childrens to be in the parent container, but they are next to it.
我的另一个问题是,我怎样才能让父元素及其所有子元素进入流动状态,以便我可以遍历子元素,例如将它们作为列表项输出。所有子代都有父代的 UID。
并且请不要告诉我使用扩展...我想学习 TYPO3 并使用 TYPO3 核心构建它:) 为了练习。
这就是我在 TCA/overrides 中的 tt_content 的样子:
对不起变量名......但我正在努力奋斗。可能有点难以理解:
'tt_content',
'CType',
['custom element', 'portfolio_list', 'content-text'],
'textmedia',
'after'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
['custom element', 'portfolio_list2', 'content-text'],
'textmedia',
'after'
);
// $GLOBALS['TCA']['tt_content']['types']['portfolio_list'] = [
// 'showitem' => '
// --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
// --palette--;;general,
// image; Image,
// header; Title,
// bodytext; Schreiben Sie einen Text,
// --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
// --palette--;;hidden,
// --palette--;;access,
// ',
// 'columnsOverrides' => [
// 'bodytext' => [
// 'config' => [
// 'enableRichtext' => true,
// 'richtextConfiguration' => 'default',
// ],
// ],
// ],
// ];
$GLOBALS['TCA']['tt_content']['types']['portfolio_list2'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
image; Image,
header; Title,
portfolio_list2;Elemente,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
',
'columnsOverrides' => [
'bodytext' => [
'config' => [
'enableRichtext' => true,
'richtextConfiguration' => 'default',
],
],
'portfolio_list2' => [
'exclude' => true,
'label' => 'Einzelnes-Portfolio',
'config' => [
'type' => 'inline',
'allowed' => 'tt_content',
'foreign_table' => 'tt_content',
'foreign_sortby' => 'sorting',
'foreign_field' => 'portfolio_list',
'minitems' => 0,
'maxitems' => 99,
'appearance' => [
'collapseAll' => true,
'expandSingle' => true,
'levelLinksPosition' => 'bottom',
'useSortable' => true,
'showPossibleLocalizationRecords' => true,
'showRemovedLocalizationRecords' => true,
'showAllLocalizationLink' => true,
'showSynchronizationLink' => true,
'enabledControls' => [
'info' => false,
],
],
],
],
],
];
// $GLOBALS['TCA']['tt_content']['columns']['header']['config']=[
// 'type' => 'inline',
// 'foreign_table' => 'tt_content',
// 'foreign_field' => 'header',
// 'foreign_sortby' => 'sorting',
// 'maxitems' => 9999,
// 'appearance' => [
// 'collapseAll' => 0,
// 'levelLinksPosition' => 'top',
// 'showSynchronizationLink' => 1,
// 'showPossibleLocalizationRecords' => 1,
// 'useSortable' => 1,
// 'showAllLocalizationLink' => 1
// ]
// ];
// $GLOBALS['TCA']['tt_content']['columns']['bodytext']['config']=[
// 'type' => 'inline',
// 'foreign_table' => 'tt_content',
// 'foreign_field' => 'header',
// 'foreign_sortby' => 'sorting',
// 'maxitems' => 9999,
// 'appearance' => [
// 'collapseAll' => 0,
// 'levelLinksPosition' => 'top',
// 'showSynchronizationLink' => 1,
// 'showPossibleLocalizationRecords' => 1,
// 'useSortable' => 1,
// 'showAllLocalizationLink' => 1
// ]
// ];
// $GLOBALS['TCA']['tt_content']['columns']['image']['config']=[
// 'type' => 'inline',
// 'foreign_table' => 'tt_content',
// 'foreign_field' => 'image',
// 'foreign_sortby' => 'sorting',
// 'maxitems' => 9999,
// 'appearance' => [
// 'collapseAll' => 0,
// 'levelLinksPosition' => 'top',
// 'showSynchronizationLink' => 1,
// 'showPossibleLocalizationRecords' => 1,
// 'useSortable' => 1,
// 'showAllLocalizationLink' => 1
// ]
// ];
$temporaryColumn = [
'portfolio_list2' => [
'exclude' => true,
'label' => 'Einzelnes-Portfolio',
'config' => [
'type' => 'inline',
'allowed' => 'tt_content',
'foreign_table' => 'tt_content',
'foreign_sortby' => 'sorting',
'foreign_field' => 'portfolio_list',
'minitems' => 0,
'maxitems' => 99,
'appearance' => [
'collapseAll' => true,
'expandSingle' => true,
'levelLinksPosition' => 'bottom',
'useSortable' => true,
'showPossibleLocalizationRecords' => true,
'showRemovedLocalizationRecords' => true,
'showAllLocalizationLink' => true,
'showSynchronizationLink' => true,
'enabledControls' => [
'info' => false,
],
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$temporaryColumn
);
// $customImage = [
// 'portfolio_list' => [
// 'exclude' => true,
// 'label' => 'Einzelnes-Portfolio',
// 'config' => [
// 'type' => 'inline',
// 'foreign_table' => 'tt_content',
// 'foreign_field' => 'teaser_field',
// 'foreign_sortby' => 'sorting',
// 'maxitems' => 9999,
// 'appearance' => [
// 'collapseAll' => 0,
// 'levelLinksPosition' => 'top',
// 'showSynchronizationLink' => 1,
// 'showPossibleLocalizationRecords' => 1,
// 'useSortable' => 1,
// 'showAllLocalizationLink' => 1
// ],
// ],
// ],
// ];
// \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $customImage);
Do I need Domain Models and make a 1:n relation or something like that? Sorry, for stupid questions. I am 2.5 months into TYPO3 and I just start my career in coding :)
I would be so thankful for any kind of help :) THX a lot!
【问题讨论】:
-
我不知道你是否可以单独使用 TYPO3...你可以使用像 gridelements 或容器这样的扩展来“嵌套”另一个内容元素中的 tt_content 内容元素;另一种选择是在不同的自定义表上定义您的子元素;看一下扩展 EXT:bootstrap_package,其中包含此类元素的几个示例(卡片、轮播...);这是一个关于如何制作自己的网站包扩展的金矿。
-
例如 TCA stackoverflow.com/questions/68691660/…。请注意,如果孩子有资产或图像,您需要一个双嵌套数据处理器
标签: typo3 typoscript fluid typo3-9.x typo3-extensions