在typo3中配置后端字段
我正在和Typo3 V8一起工作 我需要在BE中添加一些额外的字段,这样我就创建了一个扩展,允许我添加额外的字段,并且工作正常 我的问题是 所有字段都显示在所有页面中 某些字段不应出现在所有页面中在typo3中配置后端字段,typo3,typoscript,Typo3,Typoscript,我正在和Typo3 V8一起工作 我需要在BE中添加一些额外的字段,这样我就创建了一个扩展,允许我添加额外的字段,并且工作正常 我的问题是 所有字段都显示在所有页面中 某些字段不应出现在所有页面中 例如,我的主页包含一个滑块,因此在BE中我有用于上载图像的字段,但在其他页面中,我不需要显示这些字段。您可以添加一个具有额外字段的特殊doktype 假设它是doktype163,然后在ext\u localconf.phpadd中: \TYPO3\CMS\Core\Utility\Extension
例如,我的主页包含一个滑块,因此在BE中我有用于上载图像的字段,但在其他页面中,我不需要显示这些字段。您可以添加一个具有额外字段的特殊doktype 假设它是doktype163,然后在
ext\u localconf.php
add中:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
'options.pageTree.doktypesToShowInNewPageDragArea := addToList(163)'
);
将其添加到页面树上方的页面类型列表中
在同一文件中注册doktype的图标:
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconRegistry::class
)->registerIcon(
'apps-pagetree-mytype',
TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
[
'source' => 'EXT:' . $extKey . '/Resources/Public/Icons/Mytype.svg',
]
);
(当然,您需要添加svg图像或使用其他图标提供程序来注册位图)
在Configuration/TCA/Overrides/pages.php
put中:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'pages',
'doktype',
[
'Page type name',
163,
'apps-pagetree-mytype'
],
'1',
'after'
);
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][163] = 'apps-pagetree-mytype';
不是通过调用\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes()
来添加自定义字段,而是通过以下方式添加它们:
$GLOBALS['TCA']['pages']['types'][163]['showitem'] =
$GLOBALS['TCA']['pages']['types'][\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT]['showitem']
. 'the list with your new fields';
这基本上是从默认页面类型复制字段,并将其添加到自定义doktype中
当然,在XLIFF文件中使用页面类型的名称以及在代码中使用doktype编号作为常量会更好,但这需要您添加
根据doktype,您可以呈现新字段的任何内容。
希望这是添加页面类型的完整设置列表:-)您可以添加一个具有额外字段的特殊doktype 假设它是doktype163,然后在
ext\u localconf.php
add中:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
'options.pageTree.doktypesToShowInNewPageDragArea := addToList(163)'
);
将其添加到页面树上方的页面类型列表中
在同一文件中注册doktype的图标:
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconRegistry::class
)->registerIcon(
'apps-pagetree-mytype',
TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
[
'source' => 'EXT:' . $extKey . '/Resources/Public/Icons/Mytype.svg',
]
);
(当然,您需要添加svg图像或使用其他图标提供程序来注册位图)
在Configuration/TCA/Overrides/pages.php
put中:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'pages',
'doktype',
[
'Page type name',
163,
'apps-pagetree-mytype'
],
'1',
'after'
);
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][163] = 'apps-pagetree-mytype';
不是通过调用\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes()
来添加自定义字段,而是通过以下方式添加它们:
$GLOBALS['TCA']['pages']['types'][163]['showitem'] =
$GLOBALS['TCA']['pages']['types'][\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT]['showitem']
. 'the list with your new fields';
这基本上是从默认页面类型复制字段,并将其添加到自定义doktype中
当然,在XLIFF文件中使用页面类型的名称以及在代码中使用doktype编号作为常量会更好,但这需要您添加
根据doktype,您可以呈现新字段的任何内容。
希望这是添加页面类型的完整设置列表:-)