largersmallernormaltext version of this page

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011733phplistMessage Send Processpublic01-10-07 07:2110-05-10 02:03
Reporterbhugh 
PriorityhighSeverityfeatureReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Version2.10.5 
Target Version2.11.XFixed in Version 
Summary0011733: Conditional includes & placeholders, easy hack
DescriptionI put together a pretty easy way to conditionally include placeholders and other information, depending on whether a certain attribute exists or not.

So you can email "Dear Jane," to your subscribers who have entered their first name and "Good day!" to those who haven't.

Additional Informationsendemaillib.php, about line 315, find

    foreach ($user_att_values as $att_name => $att_value) {

      if (eregi("\[".$att_name."\]",$htmlmessage,$regs)) {
        $htmlmessage = eregi_replace("\[".$att_name."\]",$att_value,$htmlmessage);
      }


and replace with:

    foreach ($user_att_values as $att_name => $att_value) {

      //"CONDITIONAL" substitution thing for HTML messages, 9-30-2007
      //Works like this, in email body:
      //[CONDITIONAL Dear [FIRST NAME]|Greetings!] includes "Dear [FIRST NAME]," if [FIRST NAME] exists
      //or "Greetings!" otherwise
      //Works for any attribute name, upper case, in brackets [LAST NAME], [ZIP], etc.
      if (preg_match_all
           ('/\[CONDITIONAL\|\[' . preg_quote($att_name, '/') . '\]\|(.*?)\|(.*?)\]/si',
           $htmlmessage,$matches, PREG_SET_ORDER))
      {
       foreach ($matches as $regs) {
         if ($att_value<>"") {
            $conditional=$regs[1];
            str_replace ( '[' . strtoupper($att_name) .']', $att_value, $conditional);
         } else {
            $conditional=$regs[2];
         }
         $htmlmessage = str_replace($regs[0] , $conditional, $htmlmessage);
       }
      }

      if (preg_match_all
           ('/\[CONDITIONAL\|\[' . preg_quote($att_name, '/') . '\]\|(.*?)\|(.*?)\]/si',
           $textmessage,$matches, PREG_SET_ORDER))
      {
       foreach ($matches as $regs) {
         if ($att_value<>"") {
            $conditional=$regs[1];
            str_replace ( '[' . strtoupper($att_name) .']', $att_value, $conditional);
         } else {
            $conditional=$regs[2];
         }
         $textmessage = str_replace($regs[0] , $conditional, $textmessage); }
      }


      if (eregi("\[".$att_name."\]",$htmlmessage,$regs)) {
        $htmlmessage = eregi_replace("\[".$att_name."\]",$att_value,$htmlmessage);
      }
TagsNo tags attached.
Attached Files

- Relationships
related to 0002705closed PHPList v2.11 release 
related to 0006594new Add Fallback Feature [FirstName,Fallback=Awesome Dude] 

-  Notes
There are no notes attached to this issue.


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker