Hubris Sonic | 11 Jun 05:24
Picon

[FirstName,Fallback=Awesome Dude]

Hi,
I have coded a mod that I think would be useful. Based on the style of fallback replacements used in Campaign Monitor I code this for the /admin/sendemaillib.php file...  round about line 327, insert this...  (inside the if (is_array($user_att_values)) {  braces )


    while(preg_match_all("/\[[a-zA-Z0-9,]*Fallback=[a-zA-Z ]*\]/i",$htmlmessage,$regs)) {

    foreach($regs[0] as $tag) {

         $tokens = split(",",$tag);
         $fieldname = str_replace("[","",$tokens[0]);
         $fallback = str_replace("]","",substr($tokens[1],9));
         $found = false;
         foreach ($user_att_values as $att_name => $att_value) {
        if(strcasecmp($fieldname, $att_name)==0 && strlen($att_value)){
            $htmlmessage = str_replace($tag,$att_value,$htmlmessage);
            $found = true;
        }
         }
         if(!$found)
        $htmlmessage = str_replace($tag,$fallback,$htmlmessage);
       
       }
   }

    while(preg_match_all("/\[[a-zA-Z0-9,]*Fallback=[a-zA-Z ]*\]/i",$textmessage,$regs)) {

    foreach($regs[0] as $tag) {

         $tokens = split(",",$tag);
         $fieldname = str_replace("[","",$tokens[0]);
         $fallback = str_replace("]","",substr($tokens[1],9));
         $found = false;
         foreach ($user_att_values as $att_name => $att_value) {
        if(strcasecmp($fieldname, $att_name)==0 && strlen($att_value)){
            $textmessage = str_replace($tag,$att_value,$textmessage);
            $found = true;
        }
         }
         if(!$found)
        $textmessage = str_replace($tag,$fallback,$textmessage);
       
       }
   }


Chris

Michiel Dethmers | 11 Jun 05:41
Picon
Favicon

Re: [FirstName,Fallback=Awesome Dude]


Yes, that's nice. Did you put it on the forums, in the "mods" section so that other people might find it and in mantis.tincan.co.uk so that it will be included in the code changes?

Michiel

Hubris Sonic wrote:
Hi,
I have coded a mod that I think would be useful. Based on the style of fallback replacements used in Campaign Monitor I code this for the /admin/sendemaillib.php file...  round about line 327, insert this...  (inside the if (is_array($user_att_values)) {  braces )


    while(preg_match_all("/\[[a-zA-Z0-9,]*Fallback=[a-zA-Z ]*\]/i",$htmlmessage,$regs)) {

    foreach($regs[0] as $tag) {

         $tokens = split(",",$tag);
         $fieldname = str_replace("[","",$tokens[0]);
         $fallback = str_replace("]","",substr($tokens[1],9));
         $found = false;
         foreach ($user_att_values as $att_name => $att_value) {
        if(strcasecmp($fieldname, $att_name)==0 && strlen($att_value)){
            $htmlmessage = str_replace($tag,$att_value,$htmlmessage);
            $found = true;
        }
         }
         if(!$found)
        $htmlmessage = str_replace($tag,$fallback,$htmlmessage);
       
       }
   }

    while(preg_match_all("/\[[a-zA-Z0-9,]*Fallback=[a-zA-Z ]*\]/i",$textmessage,$regs)) {

    foreach($regs[0] as $tag) {

         $tokens = split(",",$tag);
         $fieldname = str_replace("[","",$tokens[0]);
         $fallback = str_replace("]","",substr($tokens[1],9));
         $found = false;
         foreach ($user_att_values as $att_name => $att_value) {
        if(strcasecmp($fieldname, $att_name)==0 && strlen($att_value)){
            $textmessage = str_replace($tag,$att_value,$textmessage);
            $found = true;
        }
         }
         if(!$found)
        $textmessage = str_replace($tag,$fallback,$textmessage);
       
       }
   }


Chris


Gmane