I often have the requirement to send a powermail-form to different receivers depending on a selection of a selectfield within the form. Im using TYPO3 7.6.x and Powermail 3.3.0 How can this be done?
With the help of @alex-kellner in the slackchannel of EXT:powermail i found a quite easy solution for that:
Basically there are 2 Steps needed:
Step1
Values for the Options in the select field.
You need to add values to your option in the select field. This can be done by appending a pipe |
to your option and simply add the value
MyRecieverEmail 1 | 1
MyRecieverEmail 2 | 2
MyRecieverEmail 3 | 3
In addition to that, you need to know the marker / variable / individual fieldname of your field. You can find that name in the extended
tab of your field.
You can also give this field an "own" variable name if needed. The variable is wrapped with {}
but you will not these in step 2
Step 2
Now you need to add some TS in your setupfield.
Background information: Basically this changes the reciever for a form:
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = [email protected]
Now you need to check wich option was choosen in the form. This is done by a global condition:
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]
Where yourVariableFieldname
ist the individual fieldname from the extended
tab in the field and 1
is the value of the first option (MyRecieverEmail 1)
By using this TS, the form will be send to [email protected] if the first option MyRecieverEmail 1
is choosen in the form:
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = [email protected]
[global]
You can now add as much conditions as you need. The complete example would be:
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 1]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = [email protected]
[global]
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 2]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = [email protected]
[global]
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 3]
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.value = [email protected]
[global]
Please be aware that this will be in charge for every field with the fieldname {yourVariableFieldname} in your TYPO3-Install where this TS is taken into account. This can be useful if you use this field exactly like this in multiple forms. If you dont want this to be in charge you have 2 options to avoid this:
only place the TS on the Page where your form is located.
You can add this to your global condition:
&& [globalString = GP:tx_powermail_pi1|mail|form = 123]
Where 123
is the ID of your form.
This would then look like this:
[globalString = GP:tx_powermail_pi1|field|yourVariableFieldname = 2] && [globalString = GP:tx_powermail_pi1|mail|form = 123]
Since 9.5 something like this:
[traverse(request.getParsedBody(), 'tx_powermail_pi1/field/yourVariableFieldname') == 1 ]
should works
This worked for me:
[traverse(request.getParsedBody(), 'tx_powermail_pi1/field/yourVariableFieldname') == 1 ]
plugin.tx_powermail.settings.setup {
receiver.overwrite {
email.value = MYEMAIL
email = TEXT
}
}
[END]
[traverse(request.getParsedBody(), 'tx_powermail_pi1/field/yourVariableFieldname') == 2 ]
plugin.tx_powermail.settings.setup {
receiver.overwrite {
email.value = MYEMAIL2
email = TEXT
}
}
[END]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With