Typo3 Extbase按sys类别过滤

时间:2016-06-27 09:47:53

标签: filter typo3 categories extbase

您好我使用

为我的extbase扩展启用了类别
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable

工作正常,但如何过滤要在前端显示的元素,以便后端用户可以为插件元素选择一个类别?

1 个答案:

答案 0 :(得分:1)

添加FlexForm。 为此,请将其添加到ext_tables.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'Vendor.' . $_EXTKEY,
    'Pluginname',
    'My plugin description as shown to the backend user'
);
$pluginSignature = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY)) . '_pluginname';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/myflexform.xml');

配置flexform,以便您可以选择一个类别:

<T3DataStructure>
    <sheets>
        <settings>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Settings</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <settings.myCategory>
                        <TCEforms>
                            <label>Category</label>
                            <config>
                                <type>group</type>
                                <internal_type>db</internal_type>
                                <allowed>sys_category</allowed>
                                <foreign_table>sys_category</foreign_table>
                                <size>1</size>
                                <minitems>0</minitems>
                                <maxitems>1</maxitems>
                            </config>
                        </TCEforms>
                    </settings.myCategory>
                </el>
            </ROOT>
        </settings>
    </sheets>
</T3DataStructure>

请参阅此处以供参考:https://docs.typo3.org/typo3cms/CoreApiReference/DataFormats/T3datastructure/Index.html

然后在您的Controller Action中使用该值,如$this->settings['myCategory'],并将其传递给存储库中的查询。