1

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="??"

dmckee --- ex-moderator kitten
  • 98,632
  • 24
  • 142
  • 234
Athanatos
  • 1,089
  • 6
  • 15
  • 32
  • Mmmh maybe something like this ? `$messagecontent .= $smarty->fetch('string:{#welcomemail#}...');` – sofl Dec 23 '13 at 15:09

1 Answers1

1

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

Borgtex
  • 3,235
  • 1
  • 19
  • 28