Extbase DatabaseQueryProcessor应该尊重排序

时间:2018-07-02 16:47:51

标签: typoscript extbase

如何让DatabaseQueryProcessor像在后端字段(字段“页面”的存储的逗号分隔列表)中对记录进行排序一样?

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    table = pages
    pidInList = 1
    recursive = 99
    where {
        data = field:pages
        wrap = nav_hide=0 AND uid IN (|)
    }
    as = pages
}

1 个答案:

答案 0 :(得分:0)

尝试以下未经测试的样品:

10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
    table = pages
    pidInList = 1
    recursive = 99

    where = TEXT
    where {
        data = field:pages
        wrap = nav_hide=0 AND uid IN (|)
    }

    order = TEXT
    order.stdWrap {
        field = pages

        split {
            token = ,
            cObjNum = 1|*|2

            1.current = 1
            1.trim = 1
            1.noTrimWrap = |uid=||

            2.current = 1
            2.trim = 1
            2.noTrimWrap = |, uid=||
        }
    }

    as = pages
}

基本上,我创建以下order by语句(让我们使用1,2,3作为uid样本):

Order By uid=1, uid=2, uid=3

我使用splite印刷功能,用逗号吐出uid列表,然后使用cObjNum用配置1包装第一项,用配置2包装其余项。 cObjNum的文档记录不是很好,但是您可以查看源代码单元测试以了解以下格式:\TYPO3\CMS\Core\Tests\Unit\Service\TypoScriptServiceTest::explodeConfigurationForOptionSplitProvider