在 TYPO3 中如何将类别作为嵌套数组获取?
How do you get categories as a nested array in TYPO3?
我想创建一个自定义元素来生成类别及其子类别的列表。
我的问题是类别和子类别作为一个单级数组出现。
如何生成嵌套数组以便使用 fluid 对其进行循环?
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = categories
table = sys_category
selectFields = sys_category.*
pidInList = 55
recursive = 999
as = categories
}
由于您也可以嵌套数据处理器,因此您只需确保 select 父级仅用于第一级。然后就可以根据parent的uid在second level上获取他们的children了:
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
}
}
}
不过,如果能为核心获得特定类别的处理器,那就太好了。
参见 https://forge.typo3.org/issues/82010
我想创建一个自定义元素来生成类别及其子类别的列表。
我的问题是类别和子类别作为一个单级数组出现。
如何生成嵌套数组以便使用 fluid 对其进行循环?
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = categories
table = sys_category
selectFields = sys_category.*
pidInList = 55
recursive = 999
as = categories
}
由于您也可以嵌套数据处理器,因此您只需确保 select 父级仅用于第一级。然后就可以根据parent的uid在second level上获取他们的children了:
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
}
}
}
不过,如果能为核心获得特定类别的处理器,那就太好了。 参见 https://forge.typo3.org/issues/82010