簡體   English   中英

TYPO3 DataProcessing:如何控制輸出的順序?

[英]TYPO3 DataProcessing: How to control the order of the output?

我有一個包含來自掩碼自定義內容元素的內容 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
          }
       }
    }        
}

排序字段不是我想要的。 我想要與編輯器選擇的相同的排序。

我該如何解決這個問題?

我測試了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 =

因此,不要在此處使用嵌套的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
          }
       }
    }        
}

要獲取“current”的實際字段名稱,您可能需要將<f:debug>{items}</f:debug>放入 Fluid 模板中。 或許這是data = current相反,如果實際行為current是在這種情況下可用。

據我所知,SplitProcessor 不像其他 DataProcessor 那樣支持任何進一步的 dataProcessing(至少如果沒有注意到其他選項列表中的任何 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 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
    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
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM