TYPO3 DataProcessing:如何控制输出顺序?

时间:2019-06-03 09:28:36

标签: typo3 typoscript

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

我第一次尝试使用DataProcessing。

dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
    10 {
        table = tt_content          
        uidInList.field = tx_mask_sectionmenu_contentitems    
        as = items
    }
}

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

还是我必须先检查SplitProcessor? 到目前为止,此SplitProcessor可以正常工作,但是我不知道在下一个DatabaseQueryProcessor中要指定什么?

dataProcessing {

    10 = TYPO3\CMS\Frontend\DataProcessing\SplitProcessor
    10 {
        if.isTrue.field = tx_mask_sectionmenu_contentitems
        delimiter = ,
        fieldName = tx_mask_sectionmenu_contentitems
        removeEmptyEntries = 1
        filterIntegers = 0
        filterUnique = 1
        as = items

        dataProcessing {
          10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
          10 {
            table = tt_content                          
            ???
            as = contentItem
          }
       }
    }        
}

排序字段不是我想要的。我想要编辑器选择的排序方式。

我该如何解决?

2 个答案:

答案 0 :(得分:1)

我测试了uidInList.field = tx_mask_sectionmenu_contentitems,但是它并不能使记录以逗号分隔的uid列表的顺序排序。

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

答案 1 :(得分:0)

根据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 =

因此,您可能不想跳过dataProcessing并改而去orderBy,而不是在这里使用嵌套的uidInList

  uidInList.field = tx_mask_sectionmenu_contentitems

如果您希望保留嵌套方法,则仍应使用uidInList,但略有不同

dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\SplitProcessor
    10 {
        if.isTrue.field = tx_mask_sectionmenu_contentitems
        delimiter = ,
        fieldName = tx_mask_sectionmenu_contentitems
        removeEmptyEntries = 1
        filterIntegers = 0
        filterUnique = 1
        as = items

        dataProcessing {
          10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
          10 {
            table = tt_content                          
            uidInList.field = current
            as = contentItem
          }
       }
    }        
}

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