【问题标题】:Powermail: create fields from entries in databasePowermail:从数据库中的条目创建字段
【发布时间】:2018-12-11 20:57:09
【问题描述】:

我的问题:

我需要 Powermail 中的字段矩阵:

product_1 - price_1 - number_1
product_2 - price_2 - number_2
product_3 - price_3 - number_3

等等。手动创建此字段没问题,但我需要它从数据库派生。行数取决于数据库中的条目数。

是否有可能通过打字稿或用户函数“即时”创建字段?

谢谢!

【问题讨论】:

    标签: typo3 typo3-8.x powermail


    【解决方案1】:

    我会创建一个新的字段类型并将其称为(例如)productsheet。在手册中有一个示例如何做到这一点:https://docs.typo3.org/typo3cms/extensions/powermail/ForDevelopers/AddNewFields/Index.html

    这里有两个用于新字段的示例页面 TSConfig 行:

    # Add new fields
    tx_powermail.flexForm.type.addFieldOptions.productsheet = Product Fields
    tx_powermail.flexForm.type.addFieldOptions.productsheet.dataType = 1

    这是一个示例 Productsheet.html 部分文件:

    {namespace vh=In2code\Powermail\ViewHelpers}
    
    <h2><vh:string.escapeLabels>{field.title}</vh:string.escapeLabels><f:if condition="{field.mandatory}"><span class="mandatory">*</span></f:if></h2>
    
    <table>
    	<thead>
    	<tr>
    		<th scope="col">Menge</th>
    		<th scope="col">Artikel Nr.</th>
    		<th scope="col">Bezeichnung</th>
    		<th scope="col">Preis Fr./m</th>
    	</tr>
    	</thead>
    	<tbody>
    
    	<f:for each="{0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}" as="key">
    		<tr>
    			<td>
    				<f:form.textfield type="number" class="mdl-textfield__input " name="field[{field.marker}][amount_{key}]" value="" />
    			</td>
    			<td>
    				<f:form.textfield class="mdl-textfield__input " name="field[{field.marker}][article_no_{key}]" value="" />
    			</td>
    			<td>
    				<f:form.textfield class="mdl-textfield__input " name="field[{field.marker}][description_{key}]" value="" />
    			</td>
    			<td>
    				<f:form.textfield class="mdl-textfield__input " name="field[{field.marker}][price_{key}]" value="" />
    			</td>
    		</tr>
    	</f:for>
    	</tbody>
    </table>

    下一步是动态插入字段(如您所写)。那么插入一个自己的 viewhelper 而不是在 现在您可以自己预先填写 value="" 字段。

    希望有帮助

    【讨论】:

    • 像魅力一样工作......谢谢!
    【解决方案2】:

    您可以使用 powermail 的 TypoScript 字段从打字稿生成代码。

    您也可以在页面 TSConfig 中使用您自己的字段类型,例如 here

    tx_powermail.flexForm.type.addFieldOptions.new = New Field
    
    # The label could also be written with LLL: to localize the label
    # Example to grab a value from locallang.xml or locallang.xlf
    #tx_powermail.flexForm.type.addFieldOptions.new = LLL:EXT:ext/Resources/Private/Language/locallang.xlf:label
    
    # Tell powermail that the new fieldtype will transmit anything else then a string (0:string, 1:array, 2:date, 3:file)
    # Example for dataType array
    #tx_powermail.flexForm.type.addFieldOptions.new.dataType = 1
    
    # The new field is not just a "show some text" field. It's a field where the user can send values and powermail stores the values?
    # You can tell powermail that this new field should be exportable in backend module and via CommandController
    #tx_powermail.flexForm.type.addFieldOptions.new.export = 1
    

    new是字段标识符。默认情况下,Powermail 搜索带有标识符名称的部分,例如New.html.

    现在您可以使用 ViewHelper 获取数据并为字段创建 html。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 2017-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多