【问题标题】:TypoScript select where dataWrap dynamically filled by fluid variable possible?TypoScript 选择可能由流体变量动态填充的 dataWrap?
【发布时间】:2019-01-08 13:05:31
【问题描述】:

我有自己的扩展程序,前端用户可以使用它创建自己的记录。在用户详细信息页面上,应显示用户的所有条目。

在我的“显示”模板中,我有一个变量 {user.uid},我使用它来获取用户 UID。如何将其输入到我的打字稿中?

排版

lib.getuserItems = CONTENT
lib.getuserItems {
table = tx_myext_domain_model_item
select {
    selectFields = crdate,image,message,uid,deleted
    pidInList = 2
    orderBy = crdate DESC
    where.data = 
    where.dataWrap = ((tx_myext_domain_model_item.author_ident = '{user.uid}')) AND deleted = 0 AND NOT tx_myext_domain_model_item.parent_item
}

流体

<f:cObject typoscriptObjectPath="lib.getuserItems" data="{user.uid}" />

【问题讨论】:

    标签: typo3 typoscript fluid


    【解决方案1】:

    如果您的数据是单个值(而不是数组或对象),则可以在 TypoScript 中作为 current 值使用。所以你的 TypoScript 应该是:

    lib.getuserItems = CONTENT
    lib.getuserItems {
      table = tx_myext_domain_model_item
      select {
        selectFields = crdate,image,message,uid,deleted
        pidInList = 2
        orderBy = crdate DESC
        where.current = 1
        // ensure it's an integer
        where.intval = 1
        where.wrap = ((tx_myext_domain_model_item.author_ident = '|')) AND deleted = 0 AND NOT tx_myext_domain_model_item.parent_item
      }
    }
    

    【讨论】:

    • 添加了where.intval = 1,以确保它确实是整数并避免(可能的)SQL 注入...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多