[mod] Using placeholders in the Subject line

3rd party code for phpList

[mod] Using placeholders in the Subject line

Postby korondy » 3:00pm, Thu 06 Mar, 2008

Thank you for this awesome software! I like the versatility and LOVE the price :D

Please help me further personalize my emails by allowing Placeholders in the Subject. At present, placeholders appear as "Happy Easter to the [LastName] Family!"
korondy
phpList newbie
 
Posts: 4
Joined: 6:42am, Thu 06 Mar, 2008

Postby funkypenguin » 4:52pm, Thu 06 Mar, 2008

Assuming you're using 2.10.5, there are two ways:

The easy (automatic) way

Download and uncompress the attached patch into your PHPList directory, and apply it.

the hard (manual) way

edit admin/sendemaillib.php, look for the following code from line #723 to line #732:
Code: Select all
  if (!TEST) {
    if ($hash != 'forwarded' || !sizeof($forwardedby)) {
      $fromname = $cached[$messageid]["fromname"];
      $fromemail = $cached[$messageid]["fromemail"];
      $subject = $cached[$messageid]["subject"];
    } else {
      $fromname = '';
      $fromemail = $forwardedby['email'];
      $subject = $GLOBALS['strFwd'].': '.$cached[$messageid]["subject"];
    }


DIRECTLY AFTER this code (on line #733) paste the following:

Code: Select all
    // Funky Penguin Mod starts - variable substitution in the subject
    if (is_array($user_att_values)) {
       foreach ($user_att_values as $att_name => $att_value) {
            if (eregi("\[".$att_name."\]",$subject,$regs)) {
              $subject = eregi_replace("\[".$att_name."\]",$att_value,$subject);
            }
       }
    }
    // Funky Penguin Mod ends


Now you should be able to use any user attribute variable in the subject line :)
funkypenguin
PL Nut
 
Posts: 24
Joined: 10:09am, Fri 15 Apr, 2005
Location: New Zealand

Postby korondy » 5:30pm, Thu 06 Mar, 2008

Many, many thanks, FP! (Access denied on your website, so I am doing this hard way...)
korondy
phpList newbie
 
Posts: 4
Joined: 6:42am, Thu 06 Mar, 2008

Postby funkypenguin » 11:26pm, Thu 06 Mar, 2008

Access should work now. (Sorry if it's too late!) :p
funkypenguin
PL Nut
 
Posts: 24
Joined: 10:09am, Fri 15 Apr, 2005
Location: New Zealand

Postby metroNlevel » 8:56pm, Wed 07 May, 2008

Works great :)

Thanks!

~mandy
metroNlevel
PL Nut
 
Posts: 16
Joined: 3:42am, Wed 07 May, 2008

The Mod is not fool proof

Postby Heritage » 1:27pm, Mon 11 Aug, 2008

I am pretty good with PHPlist and the mod did not work on an install of 2.10.5.

It locks up the send process. Have you submitted this for an official Mod for the next version?
Heritage
Moderator
 
Posts: 223
Joined: 3:25pm, Fri 23 Jun, 2006
Location: 800 720-7301

doesn't work for me :(

Postby Guest » 4:30am, Fri 26 Dec, 2008

Hi!

I tried this with phplist 2.10.8, and it is "processing the queue" forever (the progress bar just keeps going up and down). This is on a test setup with juts 2 subscribers!

I am using PHP 5.2.6 on Dreamhost.

I'm very new to phplist, so any help would be much appreciated!

Thanks!
/Sifaan
Guest
 

Postby deafdavid » 2:39am, Sat 27 Dec, 2008

Suggest you contact David who wrote the program at david (at) funkypenguin (dot) info. You can click his link to his website listed above.
deafdavid
PL Nut
 
Posts: 15
Joined: 5:30pm, Thu 22 Nov, 2007
Location: Washington, DC

Re: [mod] Using placeholders in the Subject line

Postby johanl2 » 7:09pm, Sat 04 Jul, 2009

Hi there,

Is there any information on how to get it work with 2.10.10? I've e-mailed the original programmer but probably he's quiet busy at the moment and isn't answering.

I've tried to get the old code work, but the lines of the code referred to seems to have changed. So I tried to find the same type of code (line 755 to 764) but when the extra bit if code is placed it isn't possible to send e-mails anymore. Trying to send a test-message leeds to the 'error' Message saved, but beneath that line it's blank, so that doesn't seem very good. Hopefully someone has a solution.

Thx very much.
johanl2
phpList newbie
 
Posts: 2
Joined: 6:59pm, Sat 04 Jul, 2009

Re: [mod] Using placeholders in the Subject line

Postby Dragonrider » 7:43pm, Sat 04 Jul, 2009

In phpList 2.10.10 the lines referred to in part one of the modification are on lines 753-762, add the Funky Penguin Mod after that, ie starting at line 763 and this moves the original code down a few lines, save the file and you can send personlised subject line emails with 2.10.10

(You may need to add the send-core fix - item 5 if necessary)

The final code in admin/sendemaillib.php should look like this (from line 753 on)
Code: Select all
if (!TEST) {
    if ($hash != 'forwarded' || !sizeof($forwardedby)) {
      $fromname = $cached[$messageid]["fromname"];
      $fromemail = $cached[$messageid]["fromemail"];
      $subject = $cached[$messageid]["subject"];
    } else {
      $fromname = '';
      $fromemail = $forwardedby['email'];
      $subject = $GLOBALS['strFwd'].': '.$cached[$messageid]["subject"];
    }
    // Funky Penguin Mod starts - variable substitution in the subject
    if (is_array($user_att_values)) {
       foreach ($user_att_values as $att_name => $att_value) {
            if (eregi("\[".$att_name."\]",$subject,$regs)) {
              $subject = eregi_replace("\[".$att_name."\]",$att_value,$subject);
            }
       }
    }
    // Funky Penguin Mod ends
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [mod] Using placeholders in the Subject line

Postby johanl2 » 7:18am, Mon 06 Jul, 2009

Thx very much! Problem must have been within the send-core.php file, but this error only showed up after adding the funky penguin mod.
johanl2
phpList newbie
 
Posts: 2
Joined: 6:59pm, Sat 04 Jul, 2009

Re: [mod] Using placeholders in the Subject line

Postby rif2006 » 10:27am, Thu 08 Sep, 2011

update about 2.10.14 works
Thx for job and explanations
rif2006
phpLister
 
Posts: 7
Joined: 2:10pm, Fri 11 Jan, 2008

Re: [mod] Using placeholders in the Subject line

Postby sintsu » 1:20am, Mon 28 Nov, 2011

Also works perfectly in version 2.10.17
THANKS for ALL the contributions you made.
sintsu
PL Nut
 
Posts: 21
Joined: 5:42am, Fri 07 Oct, 2011

Re: [mod] Using placeholders in the Subject line

Postby mikcheck » 12:06pm, Mon 26 Jan, 2015

Working in PHPLIST 3.x

IN YOUR PHPLIST FOLDER > ADMIN > sendemaillib.php

You'll find code around line 927

AFTER THIS

Code: Select all
 if (!TEST) {
    if ($hash != 'forwarded' || !sizeof($forwardedby)) {
      $fromname = $cached[$messageid]["fromname"];
      $fromemail = $cached[$messageid]["fromemail"];
      $subject = $cached[$messageid]["subject"];
    } else {
      $fromname = '';
      $fromemail = $forwardedby['email'];
      $subject = $GLOBALS['strFwd'].': '.$cached[$messageid]["subject"];
    }

PASTE THIS

Code: Select all
   // MODIFICA PER VARIABILE ES: [NOME] IN OGGETTO
    if (is_array($user_att_values)) {
       foreach ($user_att_values as $att_name => $att_value) {
            if (eregi("\[".$att_name."\]",$subject,$regs)) {
              $subject = eregi_replace("\[".$att_name."\]",$att_value,$subject);
            }
       }
    }
    // FINE MODIFICA


NOW VARIABLES (PLACEHOLDERS) ARE WORKING IN SUBJECT LINE
mikcheck
phpList newbie
 
Posts: 2
Joined: 12:02pm, Mon 26 Jan, 2015

Re: [mod] Using placeholders in the Subject line

Postby Dragonrider » 3:20pm, Mon 26 Jan, 2015

Rather than respond to two identical posts, please use This Post for any responses regarding Version 3 of phpList.

Remember that you will need to update the file each time phpList is officially updated.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom


Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 2 guests