【问题标题】:TYPO3 - Adding values to a table using powermailTYPO3 - 使用 powermail 向表中添加值
【发布时间】:2012-06-26 16:10:10
【问题描述】:

我制作了一个表格,以便用户可以注册他们的电子邮件地址以参加比赛。我使用的是 powermail 表单,有人告诉我使用 dbEntry 来执行此操作,但我不知道该怎么做。到目前为止,这是我的代码:

plugin.tx_powermail_pi1{
    dbEntry{

        tt_address._enable = TEXT
        tt_address._enable.value = 1

        tt_address.email = TEXT
        tt_address.email.value = ????
    }

    debug.output = all
}​

我被告知要激活 _enable 以启用数据插入。但是现在我不知道如何访问表单的字段值。我可能应该使用模板 ID,即###UID71###,但我不知道如何。

【问题讨论】:

    标签: typo3 typoscript


    【解决方案1】:

    根据official documentation,可以这样操作:

    plugin.tx_powermail.settings.setup {
        dbEntry {
            # enable or disable db entry for tt_address
            tt_address._enable = TEXT
            tt_address._enable.value = 1
    
            # write only if field email is not yet filled with current value
            # (update: update values of existing entry)
            # (none: no entry if field is filled)
            # (disable: always add values don't care about existing values)
            tt_address._ifUnique.email = update
    
            # fill table "tt_address" with field "pid" with the current pid (e.g. 12)
            tt_address.pid = TEXT
            tt_address.pid.data = TSFE:id
    
            # fill table "tt_address" with field "tstamp" with the current time as timestamp (like 123456789)
            tt_address.tstamp = TEXT
            tt_address.tstamp.data = date:U
    
            # fill table "tt_address" with field "name" with the value from powermail {firstname}
            tt_address.name = TEXT
            tt_address.name.field = firstname
    
            ...
        }
    }
    

    我还找到了一个(较旧的)forum post(德语),其中包含使用来自用户会话的数据的示例:

    # table "tt_address" with field "last_name" is the value from powermail (tt_content uid 88) field uid18 (###uid18###)
    tt_address.last_name = TEXT
    tt_address.last_name.data = TSFE:fe_user|sesData|powermail_88|uid18
    

    【讨论】:

    • 是的,但是如何用表单中输入之一的值填写“email”字段?最接近我想要的是最后一个例子,但我不知道“名字”是什么。
    • 它没有用。这是输入的名称属性:“tx_powermail_pi1[uid71]”,这是我使用的行:“tt_address.email.field = tx_powermail_pi1[uid71]”...
    • 你试过tt_address.name.field = uid71吗?您阅读过我链接的文档和论坛帖子吗?
    • 解决方案是:“tt_address.email.data = TSFE:fe_user|sesData|powermail_388|uid71”,其中 powermail 具有表单内容元素的 id。编辑答案,我会接受。
    • 您是否可能不使用最新版本的 powermail (2.0)?我认为最新版本使用了第一个示例中的代码。但无论如何,我从链接到我的答案的论坛帖子中复制了一些代码。
    猜你喜欢
    • 1970-01-01
    • 2022-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多