xoops forums

goffy

Just can't stay away
Posted on: 2/13 21:44
goffy
goffy (Show more)
Just can't stay away
Posts: 409
Since: 2010/12/27
#1

use line-break in tpl files

Hi

I have a specific problem in xnewsletter:
I am sending various mails based on a tpl-file.
the tpl looks e.g. like this:
Quote:
Dear {SEX} {FIRSTNAME} {LASTNAME}

You have requested the registrations of email address {EMAIL}.
This email address is currently registered for following newsletters:
{RESULT}

You can change registrations by following link:
{CHANGELINK}

-----------------------
{X_SITENAME}
({X_SITEURL})
Webmaster {X_ADMINMAIL}


To fill in this tpl I use e.g.
....      
$xoopsMailer->setTemplate('subscriptions.tpl');
.....
$xoopsMailer->assign('FIRSTNAME'$firstname);

and this is working fine.

but now I create a list of all newsletter, where someone is subscribed and it should look like
Quote:
Newsletter 1
Newsletter 2
Newsletter 3


if I use
$xoopsMailer->assign('RESULT''Newsletter 1<br>Newsletter 2<br>Newsletter 3);

I get in the mails also Quote:
Newsletter 1<br>Newsletter 2<br>Newsletter 3

the same with \r\n, \r or \n

how can I get a line break?

zyspec

Module Developer
Posted on: 2/13 22:41
zyspec
zyspec (Show more)
Module Developer
Posts: 1075
Since: 2004/9/21
#2

Re: use line-break in tpl files

@goffy,

This may depend on if you're sending the email as HTML or plain text. $xoopsMailer->setHTML(true|false);

Instead of using
$xoopsMailer->assign('RESULT''Newsletter 1<br>Newsletter 2<br>Newsletter 3);

I would suggest you try something like:
$xoopsMailer->assign('RESULT''Newsletter 1' chr(10) . 'Newsletter 2' chr(10) . 'Newsletter 3');


Let us know what you find out....

geekwright

Quite a regular
Posted on: 2/13 23:54
geekwright
geekwright (Show more)
Quite a regular
Posts: 302
Since: 2010/10/15
#3

Re: use line-break in tpl files

Quote:
goffy wrote: ... if I use
$xoopsMailer->assign('RESULT''Newsletter 1<br>Newsletter 2<br>Newsletter 3);
I get in the mails also Quote:
Newsletter 1
Newsletter 2
Newsletter 3
the same with \r\n, \r or \n how can I get a line break?
The string is defined in single quotes, so the \n and \r each are treated as 2 characters, not the control character you expect. https://www.php.net/manual/en/language ... ypes.string.syntax.single

goffy

Just can't stay away
Posted on: 2/14 15:58
goffy
goffy (Show more)
Just can't stay away
Posts: 409
Since: 2010/12/27
#4

Re: use line-break in tpl files

hi zyspec
hi geekwright

sometime you can't see the forrest because of the trees

thanks, both is working
Quote:
$xoopsMailer->assign('RESULT', 'Newsletter 1' . chr(10) . 'Newsletter 2' . chr(10) . 'Newsletter 3');

Quote:
$xoopsMailer->assign('RESULT', "Newsletter 1 \n Newsletter 2 \n Newsletter 3");