I am trying to make mailing subject lines automatically bilingual by using Smarty code, but I am running into an issue as the required code easily busts the 128 max character length for subject values.
For example, this automatic bilingual subject value:
{capture assign=l}{contact.preferred_language}{/capture}{if $l eq 'en_CA'}Spring cleaning on May 11th{else}Nettoyage du printemps le 11 mai{/if}
Gives the error "Value for subject is 145 characters - This field has a maxlength of 128 characters". Of course the resulting subject text in the mailing will be much shorter, but the Smarty version is too long for CiviMail.
I can only think of 2 ways to overcome this 128 character limitation:
- Change the subject field from a VARCHAR(128) to a VARCHAR(256) in the mailing DB table and it's matching maxlength value in the Mailing DAO code, but that would be an ugly and unmanageable hack when upgrading.
- Find way to define a $lang Smarty variable in a global scope so it can be used in the subject line without having to "capture" the value directly in the subject line. i.e. add this bit of code in a template somewhere
"{capture assign=lang}{contact.preferred_language}{/capture}"
so this bit of code is not necessary directly in the subject value.
I can't be the only one who ran into this challenge. How would you solve it?
Thanks!