phpList / phplist3

Fully functional Open Source email marketing manager for creating, sending, integrating, and analysing email campaigns and newsletters.
https://www.phplist.org
GNU Affero General Public License v3.0
746 stars 269 forks source link

Conditional variable/tags in email campaign text #1050

Closed fulldecent closed 1 month ago

fulldecent commented 2 months ago

Hello, I am preparing my first campaign in phpList, coming from Mailchimp. And I am trying to implement this kind of mail merge:

Checking in to let you know your certifications are expiring.
*|IF:ACLSEXP|* * Your ACLS expires *|ACLSEXP|* 
*|END:IF|**|IF:BLSEXP|* * Your CPR/BLS expires *|BLSEXP|*
*|END:IF|**|IF:PALSEXP|* * Your PALS expires *|PALSEXP|*
*|END:IF|**|IF:NRPEXP|* * Your NPR expires *|NPREXP|*
*|END:IF|**|IF:MTEXP|* * Your Monitor Tech certification expires *|MTEXP|*
*|END:IF|**|IF:BBPEXP|* * Your Bloodborne Pathogens expires *|BBPEXP|* *|END:IF|*

and

*|IF:CORPCODE|*https://www.XXX*|CORPCODE|**|ELSE:|*https://www.XXX*|END:IF|*

I understand the second one is easier, I could update my data source to address that.

For the first one, lines are shown or not shown in the template based on conditions (i.e. whether a variable is or is not empty).

Has anybody found a workaround for this workload? Or has anybody considered implementing conditionals in phpList's templating language, or adopting another language like php-liquid as the templating language?

Workarounds

I am considering to add extra attributes to my email list to address my specific problem above. For example I would use [LINE1] / [LINE2] / [LINE3] / [LINE4] and fill in those lines based on the first, second, third, fourth, ... expired certification.

Then in my template I would directly include [LINE1] / [LINE2] / [LINE3] / [LINE4]. The last lanes would be blank depending on how many certifications there are and the recipient would just see blank lines.

"Free"

I do understand that phplist3 is free software and anybody could implement this feature request but is under no obligation to support me.

I am opening this issue in the interest to find other people that may have also considered this use case. And also I would like to ask the maintainers here if there is appetite to merge a PR if such a feature is provided (and which design approach(es) may be acceptable).

Thank you!

bramley commented 2 months ago

There is a plugin that does something similar, see https://resources.phplist.com/plugin/conditionalplaceholder

It is no longer supported but could be used as-is, but you would need to fix any problems yourself, or as a starting-point if you wanted to implement different syntax.

fulldecent commented 1 month ago

Thank you @bramley that looks great.

I will look into using this and fork and supporting that project.

However at the moment, this is blocked for me at https://github.com/phpList/phplist3/issues/1049

Closing here as this might be out-of-scope for phplist since it can live in a module.