TYPO3数据处理:如何控制输出的顺序



我有一个列表,其中包含来自掩码自定义内容元素的内容 uid。编辑器可以从列表中选择一些内容元素。现在我想要来自这些内容元素 uid 的完整数据。所以我尝试了DatabaseQueryProcessor。

我是第一次尝试数据处理。

dataProcessing {
    10 = TYPO3CMSFrontendDataProcessingDatabaseQueryProcessor
    10 {
        table = tt_content          
        uidInList.field = tx_mask_sectionmenu_contentitems    
        as = items
    }
}

这几乎有效,但流体输出的顺序与原始列表的顺序不匹配。如何强制流体输出与原始列表中相同的顺序?

还是我必须先检查拆分处理器?这个 SplitProcessor 到目前为止可以工作,但我不知道在下一个 DatabaseQueryProcessor 中指定什么?

dataProcessing {
    10 = TYPO3CMSFrontendDataProcessingSplitProcessor
    10 {
        if.isTrue.field = tx_mask_sectionmenu_contentitems
        delimiter = ,
        fieldName = tx_mask_sectionmenu_contentitems
        removeEmptyEntries = 1
        filterIntegers = 0
        filterUnique = 1
        as = items
        dataProcessing {
          10 = TYPO3CMSFrontendDataProcessingDatabaseQueryProcessor
          10 {
            table = tt_content                          
            ???
            as = contentItem
          }
       }
    }        
}

排序字段不是我想要的。我想要与编辑器选择的相同的排序。

我该如何解决这个问题?

据我所知,SplitProcessor 不像其他 DataProcessor 那样支持任何进一步的数据处理(至少如果没有注意到任何 dataProcessing 在选项列表中像其他人一样(: https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Fluidtemplate/DataProcessing/SplitProcessor.html

这是一个解决方法,也适用于 TYPO3 11:

https://forge.typo3.org/issues/86151

总之:

dataProcessing {
    10 = TYPO3CMSFrontendDataProcessingDatabaseQueryProcessor
    10 {
        table = tt_content                          
        uidInList.field = tx_mask_sectionmenu_contentitems
        selectFields.dataWrap = *,FIND_IN_SET(uid,'{field:pages}') AS foobar_sort
orderBy = foobar_sort
        as = contentItem
    }
}
<</div> div class="one_answers">

我测试了uidInList.field = tx_mask_sectionmenu_contentitems但按逗号分隔的 uid 列表的顺序对记录进行排序没有帮助。

嵌套方法根本不起作用。我查看了代码,发现只有DatabaseQueryProcessorLanguageMenuProcessorMenuProcessor能够使用另一个 MenuProcessor 处理内容。

根据 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Fluidtemplate/Index.html#dataprocessing

  # All properties from .select can be used directly
  # + stdWrap
  colPos = 1
  pidInList = 13,14

并检查 https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Select.html 为您提供的选择属性

  uidInList =
  pidInList =
  recursive =
  orderBy =
  groupBy =
  max =
  begin =
  where =
  languageField =
  includeRecordsWithoutDefaultTranslation =
  selectFields =
  join =
  leftjoin =
  rightjoin =

因此,您可能希望跳过orderBy并改为uidInList,而不是在此处使用嵌套dataProcessing

  uidInList.field = tx_mask_sectionmenu_contentitems

如果你想继续使用嵌套方法,你仍然应该使用 uidInList,但略有不同

dataProcessing {
    10 = TYPO3CMSFrontendDataProcessingSplitProcessor
    10 {
        if.isTrue.field = tx_mask_sectionmenu_contentitems
        delimiter = ,
        fieldName = tx_mask_sectionmenu_contentitems
        removeEmptyEntries = 1
        filterIntegers = 0
        filterUnique = 1
        as = items
        dataProcessing {
          10 = TYPO3CMSFrontendDataProcessingDatabaseQueryProcessor
          10 {
            table = tt_content                          
            uidInList.field = current
            as = contentItem
          }
       }
    }        
}

要获取"当前"的实际字段名称,您可能需要将<f:debug>{items}</f:debug>放入 Fluid 模板中。也许必须data = current,如果在这种情况下可以获得current的实际行为。

最新更新