[mod] multiple content placeholder for message templates

3rd party code for phpList

[mod] multiple content placeholder for message templates

Postby danatang » 6:47am, Tue 16 Jan, 2007

Many of my administrators request multiple contents in template, so I made my solution as below:

in sendemaillib.php line:192 (original code)
///////////////////////////////////////////
if ($cached[$messageid]["template"])
# template used
$htmlmessage = eregi_replace("\[CONTENT\]",$htmlcontent,$cached[$messageid]["template"]);
else {
# no template used
///////////////////////////////////////////

And my solution is:
///////////////////////////////////////////
if ($cached[$messageid]["template"]){
# template used
$arr_content = preg_split('#\[CONTENT\]#', $htmlcontent, -1, PREG_SPLIT_NO_EMPTY);
$len = count($arr_content);
$i=0;
while($i < $len)
{
if($i == 0)
$pattern = "#\[CONTENT\]#";
else
$pattern = "#\[CONTENT".$i."\]#";
$cached[$messageid]["template"] = preg_replace($pattern,$arr_content[$i],$cached[$messageid]["template"]);
$i++;
}

$htmlmessage = $html_link.$cached[$messageid]["template"];
}else {
# no template used
///////////////////////////////////////////

The usage of multiple contents template is attached.

Besides, you can add any more contents as you need, just follow the usage.

My administrators are using the new feature very well, I do hope the improvement is helpful for all of you. If possible, the enhancement can be added to the next version of phplist.

EDIT: See also http://mantis.phplist.com/view.php?id=8970
Last edited by danatang on 7:41am, Tue 16 Jan, 2007, edited 1 time in total.
danatang
phpLister
 
Posts: 5
Joined: 3:09am, Thu 11 Jan, 2007

How can i upload my usage file (template.rar)

Postby danatang » 7:26am, Tue 16 Jan, 2007

Sorry, I cannot upload my usage file (template.rar just 68 KB). Any help?

EDIT: See http://mantis.phplist.com/view.php?id=8970
danatang
phpLister
 
Posts: 5
Joined: 3:09am, Thu 11 Jan, 2007

Postby Hernol » 2:28pm, Tue 16 Jan, 2007

Great, can you add an issue here http://mantis.phplist.com/ and upload the files?
Hernol
Admin
 
Posts: 1378
Joined: 6:39pm, Thu 18 May, 2006
Location: Argentina

Second place holder doesn't work.

Postby mscruse » 11:20pm, Tue 23 Jan, 2007

Hello

This is a great solution and exactly what I need. I have made the modifications to the sendemaillib.php and created my template with two content place holders:

[CONTENT]

and

[CONTENT1]

When I send a message all my content appears in the first [CONTENT] place holder.

I created my content like this example:


Test test test 1 2 3

Blah blah blah

Testing 1 2 3

[CONTENT]
More content

This is the second place holder


This is what you had in your example word document.

Is there something that I am doing wrong?

I have attached my template file for you to look at.

Many thanks
Michael.
mscruse
phpLister
 
Posts: 7
Joined: 5:06am, Tue 17 Oct, 2006

Postby danatang » 1:01am, Wed 24 Jan, 2007

Hi,
Did you mark this line in sendemaillib.php as below?

//$htmlmessage = $html_link.eregi_replace("\[CONTENT\]",$htmlcontent,$cached[$messageid]["template"]);
danatang
phpLister
 
Posts: 5
Joined: 3:09am, Thu 11 Jan, 2007

THANK YOU

Postby mscruse » 1:23am, Wed 24 Jan, 2007

Hello

Thank you for the resolution. I had just commented it out with # but as soon as I changed it to // it worked perfectly.

Many thanks
Michael.
mscruse
phpLister
 
Posts: 7
Joined: 5:06am, Tue 17 Oct, 2006

Postby kurieuo » 11:56am, Sat 05 May, 2007

I have not tested this solution, but I agree this feature is a must. And with code already existing, would I'd think make it much easier to implement. :)
kurieuo
phpList newbie
 
Posts: 2
Joined: 7:53am, Mon 05 Mar, 2007

This causes a bug

Postby bizzynate » 2:32pm, Fri 08 Aug, 2008

I have discovered that your hack causes a very serious bug with respect to currency values in the message body. For example:

"It costs $35 to go..."

becomes

"It costs to go..."

It appears that somehow your hack is preventing the use of something that resembles a PHP variable. You might wish to rethink this a little. Also, please do us all a favor and make a note of your findings in Mantis, so this bug doesn't get released.
bizzynate
phpList newbie
 
Posts: 2
Joined: 10:34pm, Tue 23 Oct, 2007

Postby Guest » 4:42am, Fri 14 Nov, 2008

This was working fine in our previous version of phplist but now I cannot get it to work. Our current version is 2.10.5. Any ideas?
Guest
 

Postby bizzynate » 7:32pm, Sat 15 Nov, 2008

Kate, did you reapply the hack after upgrading? The upgrade would have replaced the files that you had previously hacked...
bizzynate
phpList newbie
 
Posts: 2
Joined: 10:34pm, Tue 23 Oct, 2007

Postby Guest » 3:46am, Thu 27 Nov, 2008

I'm a little confused by this. In the message, does the [CONTENT] placeholder go before or after the content it refers to?

Is it:

this is text of first content
[CONTENT]
This is text of the sceond content
[CONTENT]

OR

[CONTENT]
This is the text of the first content
[CONTENT]
This is the text of the second content

One other question. If I define 3 Contents in the templlate and only define 2 in the message, what happens?

Thanks,
Pete
Guest
 

Postby Guest » 5:15am, Thu 27 Nov, 2008

I figured out the answer to the previous reply I posted.

Everything seems to be working fine but I'm getting the problem with dollar amounts disappearing. Has anyone figured out how to fix this? I probably can't use this mod unless that's fixed since most of my messages have a $ amount somewhere in them.

Thanks,
Pete
Guest
 

Postby rjc » 9:03pm, Sun 28 Dec, 2008

Copy Pasted from the Mantis link for those who didn't look there, a fix for the $ bug; haven't tried it yet to know if it works, assume it does:


Danatang wrote on 11/08/08:

Thanks bizzynate!

I made fix as below:
//////////////////////////////////////////////////////////////////////
if ($cached[$messageid]["template"]){
# template used
$arr_content = spliti('\[CONTENT\]', $htmlcontent);
$len = count($arr_content);
$i=0;
while($i < $len)
{
if($i == 0)
$pattern = "\[CONTENT\]";
else
$pattern = "\[CONTENT".$i."\]";
$cached[$messageid]["template"] = eregi_replace($pattern,$arr_content[$i],$cached[$messageid]["template"]);
$i++;
}
$htmlmessage = $html_link.$cached[$messageid]["template"];
}else {

..............


Just please don't use it to send out messages such as "Office 2007 Pro: $99" :x
rjc
PL Nut
 
Posts: 28
Joined: 10:57pm, Mon 11 Dec, 2006

Re: [mod] multiple content placeholder for message templates

Postby steveoriol » 3:13pm, Tue 14 Jun, 2011

I like this [mod] ;-)
steveoriol
phpList newbie
 
Posts: 4
Joined: 12:44pm, Wed 24 Jun, 2009


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

Who is online

Users browsing this forum: No registered users and 1 guest

cron