目前我正在使用一个电子邮件通知表单,我有大约二十个与会者.我使用这些值显示在电子邮件通知中.我的代码是:
{% AttendeeFirstName %} {% AttendeeLastName %}
{% AttendeeFirstName2 %} {% AttendeeLastName2 %}
{% AttendeeFirstName3 %} {% AttendeeLastName3 %}
{% AttendeeFirstName4 %} {% AttendeeLastName4 %}
{% AttendeeFirstName5 %} {% AttendeeLastName5 %}
{% AttendeeFirstName6 %} {% AttendeeLastName6 %}
{% AttendeeFirstName7 %} {% AttendeeLastName7 %}
{% AttendeeFirstName8 %} {% AttendeeLastName8 %}
{% AttendeeFirstName9 %} {% AttendeeLastName9 %}
{% AttendeeFirstName10 %} {% AttendeeLastName10 %}
{% AttendeeFirstName11 %} {% AttendeeLastName11 %}
{% AttendeeFirstName12 %} {% AttendeeLastName12 %}
{% AttendeeFirstName13 %} {% AttendeeLastName13 %}
{% AttendeeFirstName14 %} {% AttendeeLastName14 %}
{% AttendeeFirstName15 %} {% AttendeeLastName15 %}
{% AttendeeFirstName16 %} {% AttendeeLastName16 %}
{% AttendeeFirstName17 %} {% AttendeeLastName17 %}
{% AttendeeFirstName18 %} {% AttendeeLastName18 %}
{% AttendeeFirstName19 %} {% AttendeeLastName19 %}
在上面,如果任何与会者都有价值,那么工作正常.但是这里有一个问题是,如果用户使用了两个与会者,那么两个与会者正在展示,但对于其他18个,它显示大的空白区域然后在那之后使用的任何字段是展示.如果电子邮件通知中没有为该与会者提供任何值,我该如何删除此空格.
In the below code i used as for loop but not getting the value.
{% size = GroupSize;attName="";j=0;for(i=0; i < size; i++){if(j==0){attName+=AttendeeFirstName+ " "+AttendeeLastName}else if(j>0){
attName+=AttendeeFirstName+j+ " "+AttendeeLastName+j}j+=1;}; attName#%}
以下是rock建议使用的代码:
Additional Attendees:
{% att1 = AttendeeFirstName + " " + AttendeeLastName; if(att1 != " ") { return att1; } else { return ""; } #%}
{% att2 = AttendeeFirstName1 + " " + AttendeeLastName1; if(att2 != " ") { return att2; } else { return ""; } #%}
{% att3 = AttendeeFirstName2 + " " + AttendeeLastName2; if(att3 != " ") { return att3; } else { return ""; } #%}
{% att4 = AttendeeFirstName3 + " " + AttendeeLastName3; if(att4 != " ") { return att4; } else { return ""; } #%}
在上面的代码中,如果我们只使用FirstName,那么对于其他代码,电子邮件通知中会有一些空间.
我想大空白是由括号之间的空间引起的: %} {%
建议没有.1:您不必单独使用代码块.
{% AttendeeFirstName + " " + AttendeeLastName %}
建议没有.2:使用条件.
{% list = ""; br = "
"; att1 = AttendeeFirstName + " " + AttendeeLastName; if(att1 != " ") { list += att1+br; } att2 = AttendeeFirstName1 + " " + AttendeeLastName1; if(att2 != " ") { list += att2+br; } att3 = AttendeeFirstName2 + " " + AttendeeLastName2; if(att3 != " ") { list += att3+br; } att4 = AttendeeFirstName3 + " " + AttendeeLastName3; if(att4 != " ") { list += att4; } return list; #%}
建议没有.3:使用循环.我不知道你如何存储你的数据,但迭代一个集合而不是硬编码所有二十个参与者会更加清晰.
建议没有.4:看一下宏语法文档,特别是条件和循环.