【问题标题】:Typo3 V9 select random DCE from whole page to show on specific pageTypo3 V9 从整个页面中选择随机 DCE 显示在特定页面上
【发布时间】:2020-04-14 14:13:58
【问题描述】:

我有一个自己的 DCE 元素,我想在起始页上显示一个随机元素。
当我通过10 = CONTENTselect 选择CType 时,我必须输入pidInList
但我想要整个站点的 CE,而不是特定的 uid。

如何在 sql 语句中禁用此功能?

我当前的代码:

        10 = CONTENT
        10 {
            table = tt_content
            select {
                selectFields = *, rand() as virt_rnd
                pidInList = *
                where = colPos=0 and CType=dce_ref
                max = 1
                orderBy = virt_rnd
                languageField = sys_language_uid
            }

【问题讨论】:

    标签: typo3 typoscript typo3-9.x tx-dce


    【解决方案1】:

    你可以使用:

      select {
        selectFields = *
        pidInList = root
        recursive = 10
        orderBy = rand()
        where = colPos=0 and CType=dce_ref
        max = 1
        languageField = sys_language_uid
      }
    

    使用根页面 (uid = 0) 和 10 级深的所有页面(如果您的页面树更深,则使用更多)

    【讨论】:

    • 谢谢,但这会引发错误:“订单子句”中的未知列“rand()”我首先删除了 orderBy,结果为空。使用不正确的 sql,我从中得到以下 sql 语句:SELECT * FROM `tt_content` WHERE (`tt_content`.`uid` = 0) AND (colPos=0 and CType='dce_ref') AND (`sys_language_uid` IN (0, -1)) AND ((`tt_content`.`deleted` why they want uid=0?
    【解决方案2】:

    Typo3 v10 更新

    排版:

    lib.randomDCE = CONTENT
    lib.randomDCE {
        table = tt_content
        select {
            pidInList = 1  // root page id
            recursive = 10
            where = {#colPos}=0 AND {#CType}='my_custom_element'
            max = 1
            languageField = sys_language_uid
            //orderBy = rand()    - does not work :-(
        }
    }
    

    在流体模板中使用:

    <f:cObject typoscriptObjectPath="lib.randomDCE" />
    

    【讨论】:

    • 我尝试使用随机排序,但没有成功.. (
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多