2

我使用此代码显示我在第 68 页的 tt_address 中拥有的寄存器数量,并且工作正常,只是它不显示隐藏元素。

# Default PAGE object:
page = PAGE
page{
  20 = CONTENT
  20 {
    table = tt_address

    select{
      selectFields = count(uid) AS count
      pidInList = 68
      where = deleted = 0
    }

    renderObj = COA
    renderObj {
      10 = TEXT
      10 {
        value = Status: {field:count}
        insertData = 1
      }
    }
  }
}

我怎么能把隐藏的记录也算在内?

4

4 回答 4

1

我认为使用打字稿获取隐藏记录是不可能的(不能选择来自隐藏、定时或访问受保护页面的记录!)。参考链接:http ://wiki.typo3.org/TSref/select

您可能需要使用“userfunc”,如下所示:

排版:

includeLibs.showHiddenElements = fileadmin/lib/showHiddenElements.php
page.20  =USER
page.20  {
 userFunc =user_showHiddenElements->main
 field = uid
 table = tt_address
 where = deleted = 0 and pid = 68
}

文件管理员/lib/showHiddenElements.php:

<?php
class user_ShowHiddenElements {
 function main($content, $conf){
    $res=  $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
                $conf[field],         // SELECT ...
                $conf[table],     // FROM ...
                $conf[where],    // WHERE...
               '',            // GROUP BY...
               '',    // ORDER BY...
               ''            // LIMIT ...
            );
    return $res;
 }
}
?>
于 2013-02-07T07:36:25.280 回答
0

您不能以正常方式绕过“启用字段” where 子句,但 TYPO3 允许使用UNION查询来解决这个问题:

select {
    selectFields = count(uid) AS count
    pidInList = 68
    where.data = TSFE:id
    # we hack our way around the enablefields restriction
    where.wrap = 0 UNION SELECT COUNT(*) as count FROM tt_address WHERE pid = 68
}
于 2013-02-07T08:55:26.987 回答
0

另一种解决方案:

page{
24 = CONTENT
24.wrap = <div class="status_count">|</div>
24 {
    table = tt_address
    select {
        selectFields = count(uid) AS count
        pidInList = 68
        where.data = TSFE:id
        # we hack our way around the enablefields restriction
        where.wrap = |0 UNION SELECT COUNT(*) as count FROM tt_address WHERE pid = 68
    }
    renderObj = COA
    renderObj {
        10 = TEXT
        10.wrap = |</div><div style="display:none">
        10 {
            value = Status: {field:count}
            insertData = 1
        }
    }
}
}

感谢 cweiske 给了我这个想法。

于 2013-02-07T09:58:17.930 回答
0

就是这样:例如仅显示已删除或隐藏的页面

table = pages
select.pidInList = 1
select.where = deleted=1 or hidden=1 UNION SELECT * FROM pages WHERE 1=0

这有效,因为启用字段被附加到查询中。Union with 1=0 where 子句与 enablefields 不返回任何内容。

于 2013-11-26T09:50:54.457 回答