Вопрос

In my php file to send emails I would like to use smarty config variables however currently I have to cut them

This is part of the PHP file:

PHP

$messagecontent  .= "
<p>bla bla bla bla  <b> $username </b> xxxx <b> $myitemname </b>
    <p>When you receive xxx go to xxxx</p>
feel free to <a href=".WEBSITEHOST."contact-us.php>contact us </a> at any time.<br />";

Currently I am creating different smarty config vars like so:

$messagecontent  .= $smarty->getConfigVariable('welcomemail1'). $username $smarty->getConfigVariable('welcomemail2'). $myitemname." </b>
    <p>When you receive xxx go to xxxx</p>
feel free to <a href=".WEBSITEHOST."contact-us.php>contact us </a> at any time.<br />";

Can I do all at once somehow (include the php vars in the smarty config files)

So: $messagecontent =$smarty->getConfigVariable('welcomemail');

And how will {#welcomemail#} include those? e.g welcomemail="??"

Это было полезно?

Решение

you can use sprintf

i.e. in your config file you will have

welcomemail = "bla bla bla %1$s blablabla %2$s ...."

and then in php

$messagecontent = sprintf ($smarty->getConfigVariable('welcomemail'),$username,$itemname);

However, I think that the easiest and most flexible way to create mails is to write a template for the body of the mail, process it with smarty and get the output in a variable instead of displaying it on the screen

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top