如何在TYPO3的自定义模型中使用/链接sys_category字段

时间:2018-07-03 09:10:04

标签: typo3 typo3-8.x typo3-extensions

我正在开发一个扩展程序,其中我要上传文件,对于每个文件上传,我都需要具有一个或多个与之关联的类别。

我已经建立了一个自定义类别模型,并且在创建记录时它在后端显示得很好,但是我想显示/链接sys_category记录而不是我自己的自定义类别。

如何在自定义模型中链接该字段?

1 个答案:

答案 0 :(得分:0)

如果其他人偶然发现了这个问题,我可以通过@ larry-pete从文档中找到解决方案。

只需将这些行添加到扩展文件夹中的ext_tables.php文件中即可。

// Add an extra categories selection field to the pages table
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
        'ext_key',
        'your_table_name',
        'categories',
        array(
            // Set a custom label
            'label' => 'LLL:EXT:ext_key/Resources/Private/Language/locallang.xlf:additional_categories',
            // This field should not be an exclude-field
            'exclude' => FALSE,
            // Override generic configuration, e.g. sort by title rather than by sorting
            'fieldConfiguration' => array(
                'foreign_table_where' => ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC',
            ),
            // string (keyword), see TCA reference for details
            'l10n_mode' => 'exclude',
            // list of keywords, see TCA reference for details
            'l10n_display' => 'hideDiff',
        )
    );

希望它可以帮助某人。