简体   繁体   English

如何在 TYPO3 中将类别作为嵌套数组获取?

[英]How do you get categories as a nested array in TYPO3?

I want to make a custom element that produces a list of categories and their subcategories.我想制作一个自定义元素来生成类别及其子类别的列表。

My problem is the categories and subcategories come through as one single level array.我的问题是类别和子类别作为一个单级数组出现。

How can I produce a nested array so I can use fluid to loop over it?我怎样才能产生一个嵌套数组,以便我可以使用流体循环它?

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
        if.isTrue.field = categories
        table = sys_category
        selectFields = sys_category.*
        pidInList = 55
        recursive = 999
        as = categories
}

Since you can nest data processors too, you just have to make sure to select parents only for the first level.由于您也可以嵌套数据处理器,因此您只需确保 select 父级仅用于第一级。 Then you can get their children on the second level based on the parent's uid:然后你可以根据父级的uid让他们的子级进入第二级:

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
        if.isTrue.field = categories
        table = sys_category
        selectFields = sys_category.*
        pidInList = 55
        recursive = 999
        where = parent = 0
        as = categories
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            10 {
                    table = sys_category
                    selectFields = sys_category.*
                    pidInList = 55
                    recursive = 999
                    where.dataWrap = parent = {field:uid}
                    as = subcategories
            }
        }
}

Still it would be nice to get a specific category processor for the core.为核心获得特定类别的处理器仍然会很好。 See https://forge.typo3.org/issues/82010https://forge.typo3.org/issues/82010

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM