View Issue Details

IDProjectCategoryView StatusLast Update
0008970phpList 3 applicationTemplate Managementpublic19-07-14 14:05
Reporterdanatang 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionopen 
Product Version2.10.4 
Target VersionFixed in Version 
Summary0008970: multiple contents placeholder for template and my solution
DescriptionMany 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.

TagsNo tags attached.

Relationships

related to 0002705 closed PHPList v2.11 release 

Activities

18-01-07 01:04

 

template.doc (121,856 bytes)

bizzynate

08-08-08 15:41

reporter   ~0050170

This hack creates a bug. US Currency values are removed from templates upon sending. For example:

"It costs $35 to go..."

becomes

"It costs to go..."

This appears to be misinterpreted as a php variable. This core feature should NOT be released until this issue is resolved as it will be a major factor for anyone who needs to use a legitimate $ as part of content and not as a variable.

danatang

11-08-08 06:55

reporter   ~0050180

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 {

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

michiel

12-11-12 13:15

manager   ~0051895


Yes, it's nice to do something like that, but I've marked it feature for now.

One question though, if you have multiple "CONTENT" field, how do you get your editors to edit the different contents? Are you duplicating the Textarea and allowing them to input the different contents in different places?

I think making a sensible interface for that is more than just a few regex-changes.

michiel

19-07-14 14:05

manager   ~0054341

closing. No feedback for more than a year.